So I have pulled two bits of code that worked well separately, but don't go well together. One is for a select case within some pivot table code to pass through values in the case as pivottable filters. Another is trying to loop through a number of values to get them passed through to the case statement.
What I'm hoping for is that I will have a number of values in some rows in column A, and I'd like to pass all fo those values through as filters in a pivot table, but anything no in this list of values should not be filtered. However, the way the code works is that it goes through each value in my list and if its not that value, it doesn't get filtered. I knwo this is a coding mistake but I'm not sure how to fix it. My loop using the variable j could have anywhere from 1 value to 180, but the select case will only pick the very last one, exactly as the code says. how can i pass all of these values through the case statement all at once and eliminate the loop around the Select-Case?
What I'm hoping for is that I will have a number of values in some rows in column A, and I'd like to pass all fo those values through as filters in a pivot table, but anything no in this list of values should not be filtered. However, the way the code works is that it goes through each value in my list and if its not that value, it doesn't get filtered. I knwo this is a coding mistake but I'm not sure how to fix it. My loop using the variable j could have anywhere from 1 value to 180, but the select case will only pick the very last one, exactly as the code says. how can i pass all of these values through the case statement all at once and eliminate the loop around the Select-Case?
Code:
With PivotTbl.PivotFields("Product")
For i = 1 To .PivotItems.Count
With .PivotItems(i)
FormShtLastRow = FormSheet.Cells(Rows.Count, 1).End(xlUp).Row
If FormShtLastRow > FormShtBlackRow + 1 Then
For j = FormShtBlackRow + 2 To FormShtLastRow
Select Case .Name
Case FormSheet.Cells(j, 1).Value
.Visible = True
Case Else
.Visible = False
End Select
Next j
End If
End With
Next i
End With