VBA to Automatically Update Pivot Table Dates

Jar888

Board Regular
Joined
Jan 15, 2022
Messages
61
Office Version
  1. 2016
Platform
  1. Windows
Is there a way to update dates automatically using VBA in a pivot table?

I've slowly been changing a lot of spreadsheets and updating how formulas and reading things goes, but I'm just not sure what direction to go in with this one, weather I need to redo the spreadsheet or not.

I've got 4 pivot tables that draw information from a data input sheet, which then does some calculations to show down time across my workplace. Two pivot tables are a single date input for the day before today and the other two are a multiple date input for the current month from the 1st until the day before today.

Any help would be greatly appreciated

1666330928061.png

1666330958614.png
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
In the Project Explorer (Alt+F11), select the Sheet that contains the Pivot tables;
In the Object drop-down box, select Worksheet. In the Procedure drop-down box, select Change event .

Example :


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    ActiveSheet.PivotTables("SHOTCRETE DELAYS").RefreshTable
    ActiveSheet.PivotTables("CBOLT DELAYS").RefreshTable

End Sub

For each Spreadsheet
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,806
Members
449,048
Latest member
greyangel23

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