Code Problem
Drew wrote:
I am trying to click on a command button in a worksheet that will refresh
pivot tables and ODBC connections throughout my workbook. The code seems to
work well to refresh the pivot tables, but once it hits the ODBC data it
errors out.
Can someone help me with my code?
Sheets("Sheet1").PivotTables("PivotTable1").Refres hTable
Sheets("Sheet2").PivotTables("PivotTable1").Refres hTable
Sheets("Sheet3").Select
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Sheet4").Select
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Maybe this will work better for you. Works equally well for pivot tables
and ODBC sources.
Sub RefreshAllPivotTables_n_Such()
ActiveWorkbook.RefreshAll
End Sub
|