I created an Excel file to be used as a template for an Excel export from a vendor database application.
When I run this export, it fills in the data.
I have three queries pulling from this data export.
In the Worksheet, I have two pivot tables and one graph reading from these queries.
In order for the pivot tables and graphs to refresh based on the export, I have to Refresh All twice.
I assume I have to do it twice because of the cascading data sequence.
When I create a macro button for this, I am not able to replicate the manual process of Refresh All twice.
Instead, I still have to press the macro button twice.
Is there a way to alter the code, so a user only has to press the macro button once?
Sub RefreshAllData()
'
' RefreshAllData Macro
' Refresh Twice
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim Sheet As Worksheet, Pivot As PivotTable
ActiveWorkbook.RefreshAll
For Each Sheet In ActiveWorkbook.Worksheets
For Each Pivot In Sheet.PivotTables
Pivot.RefreshTable
Pivot.Update
Next
Next
MsgBox "Graph and pivot tables are refreshing."
ActiveWorkbook.RefreshAll
End Sub
I even tried calling this function twice, but it doesn't work.
Please advise.
Bookmarks