Problem with a macro

kylefraney

Board Regular
Joined
Mar 21, 2003
Messages
127
There seems to be problem with the below code, specifically the Refresh BackgroundQuery. Any help would be appreciated.

Sub Update()
'
' Update Macro
' Macro recorded 10/25/2006 by
'

'
Sheets("ParameterQuery").Select
Range("A2").Select
'ActiveWorkbook.RefreshAll
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Expenses").Select
Range("B5").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
End Sub
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,915
Office Version
  1. 365
Platform
  1. Windows
What is the problem?

Does this help?
Code:
Sub Update()
    Sheets("ParameterQuery").Range("A2").QueryTable.Refresh BackgroundQuery:=False
    Sheets("Expenses").PivotTables("PivotTable1").PivotCache.Refresh
End Sub
 

kylefraney

Board Regular
Joined
Mar 21, 2003
Messages
127
Okay I fixed that now I'm getting a run-time error "1004"
Unable to get PivotTables property of the Worksheet class

It seems to having the error on this line

"Sheets("Expenses").PivotTables("PivotTable1").PivotCache.Refresh"

As always, any help would be appreciated.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,990
Messages
5,545,361
Members
410,679
Latest member
rolandbianco
Top