jdbienenfeld
New Member
- Joined
- Jun 30, 2018
- Messages
- 1
I am trying to build a macro to refresh multiple pivot tables in a loop without having to use the name of the pivot table "PivotTable1", etc.. I found this code:
Sub UpdateWorkStreamIssues_LOOP()
'
Sheets("Ambulatory").Select
' UpdateWSIssues Macro LOOP
Dim pt As PivotTable
For i = 1 To 2
ActiveSheet.Select
Range("A1").Select
pt.RefreshTable
Sheets(ActiveSheet.Index + 1).Activate
Next
End Sub
I get this error: "RuntimeError 91: Object variable or with block variable not set" for the code "pt.RefreshTable"
What am I doing wrong?
Sub UpdateWorkStreamIssues_LOOP()
'
Sheets("Ambulatory").Select
' UpdateWSIssues Macro LOOP
Dim pt As PivotTable
For i = 1 To 2
ActiveSheet.Select
Range("A1").Select
pt.RefreshTable
Sheets(ActiveSheet.Index + 1).Activate
Next
End Sub
I get this error: "RuntimeError 91: Object variable or with block variable not set" for the code "pt.RefreshTable"
What am I doing wrong?