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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,053
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,118,296
Messages
5,571,396
Members
412,386
Latest member
Yasaman
Top