I am currently working on a VBA project which is working for the most part. However I've noticed that, when left to run on it's own (without utilizing F8), the code does not always assign a value to the variable. Can not figure out why and thought another set of eyes could figure out the issue. Code below:
Code:
Case "Tact Integ"
PivItem = Sheets(3).PivotTables(1).PivotFields("PRJTASK")
For Each PivItem In PT.PivotFields("PRJTASK").PivotItems
Select Case Mid(PivItem.Name, 10, 2)
Case "7A", "7T", "7R", "7S", "7M", "7J", "7W"
PivItem.Visible = True
Call TaskSelect
Case Else
PivItem.Visible = False
End Select
Next PivItem
To give some background, there is a drop down box with multiple choices. When one is chosen, the code goes into action based on the selected choice (case). Once the coorect case is selected, it is supposed to assign the value of "PivItem" as the current value of the pivot field "PRJTASK". As you may be able to tell from the code above, based on the last two digits of the pivot item, the code them decides whether to set the pivot item as visible or non-visible.
The variable PivItem has been declared as a public variant and seems to work when I manually go line by line via F8, however, when I try to run the code from the worksheet (as intended) it does not always assign the value. Is there something that i'm doing wrong??
Mike