I can't get this VBA to work - I need some help troubleshooting

russelldt

Board Regular
Joined
Feb 27, 2021
Messages
160
Office Version
  1. 365
Platform
  1. MacOS
I have a Pivot table that has 1 filter " Job number". The filter value I want to use, appears in cell D1. I want the table to filter automatically to the cell D! value, when I open the file. On the Pivot Table options, I have set the Date to Refresh data when opening file.
The table name is "Invoice", and the sheet for the Pivot table and cell D1 is "Cashflow summary"


I don't know why its not working.

Any help would be appreciated. Here is the VBA I have:




Sub UpdatePivotFilter()
Dim NewFilterValue As String
NewFilterValue = Worksheets("Cashflow summary").Range("D1").Value
Worksheets("Cashflow summary").PivotTables("Invoice").PivotFields("Job Number").CurrentPage = NewFilterValue
End Sub
 

Attachments

  • Screenshot 2023-09-18 at 8.27.57 AM.png
    Screenshot 2023-09-18 at 8.27.57 AM.png
    15.9 KB · Views: 22

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,023
Latest member
alabaz

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