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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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