Hi,
I'm still quite new to doing VBA and kinda blocked on this matter. I tried to look around and can't seem to find the answer I'm looking for, maybe I'm just not searching the right keywords.
So to explain quick I'm trying to filter a pivottable (Let's say table one) with data from an other pivottable(Table 2).
The Table one contains all the article in the warehouse with multiple informations and the second are only the articles I wanna work with for the day.
So my code look like this for now,
Dim lastrow As Long
Dim Pti As PivotItem
Dim i As Long
lastrow = Sheets("Pivots").Cells(Rows.Count, 6).End(xlUp).Row
On Error Resume Next
For Each Pti In Sheets("Pivots").PivotTables("PivotTable2").PivotFields("Article").PivotItems
If Pti.Value <> Range("Q6" & lastrow) Then
Pti.Visible = False
End If
Next Pti
End Sub
If I do : If Pti.Value <> Range("Q6") Then : It works to show only the cell value of Q6 altough it takes a long time since there is over 20.000 articles.
So I'd like to know first how to apply it to Q6 to the last value of the same columns and secondly I'm open to learn any other method that would go faster.
Thanks for the help !
I'm still quite new to doing VBA and kinda blocked on this matter. I tried to look around and can't seem to find the answer I'm looking for, maybe I'm just not searching the right keywords.
So to explain quick I'm trying to filter a pivottable (Let's say table one) with data from an other pivottable(Table 2).
The Table one contains all the article in the warehouse with multiple informations and the second are only the articles I wanna work with for the day.
So my code look like this for now,
Dim lastrow As Long
Dim Pti As PivotItem
Dim i As Long
lastrow = Sheets("Pivots").Cells(Rows.Count, 6).End(xlUp).Row
On Error Resume Next
For Each Pti In Sheets("Pivots").PivotTables("PivotTable2").PivotFields("Article").PivotItems
If Pti.Value <> Range("Q6" & lastrow) Then
Pti.Visible = False
End If
Next Pti
End Sub
If I do : If Pti.Value <> Range("Q6") Then : It works to show only the cell value of Q6 altough it takes a long time since there is over 20.000 articles.
So I'd like to know first how to apply it to Q6 to the last value of the same columns and secondly I'm open to learn any other method that would go faster.
Thanks for the help !