Hi Gurus,
I am trying to refresh individually different tables(Data connections from share point) in my workbook. I don't want to use Refresh all as it will affect the pivot tables.
This is the code I got using macro recorder.
Can some one guide me on this please?
I am trying to refresh individually different tables(Data connections from share point) in my workbook. I don't want to use Refresh all as it will affect the pivot tables.
This is the code I got using macro recorder.
Code:
Private Sub RefreshTables()'
Application.ScreenUpdating = False
Sheets("Trend").Activate
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Plan").Activate
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Finance").Activate
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Architecture").Activate
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("MCP").Activate
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("Program").Activate
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub
- Am getting an Run-time error "91': Object variable or With block variable not set error.
- How can I clean this code up?
Can some one guide me on this please?