VBA trying to define a range to filter my pivot with an other pivot table

SamDof

New Member
Joined
May 22, 2021
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
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 !
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top