vba command line to refresh a pivottable.

S

synergy46

Version: 2004 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I have a sheet (sheet1) and a pivot table (PT). I have implemented the command line indicated in the help files as follows:

Sub pivot()
Set pvtTable = Sheet1.PivotTables(PT).PivotCache.Refresh
End Sub

What am I doing wrong? Thanks
 
J

JE McGimpsey

Version: 2004
Operating System: Mac OS X 10.6 (Snow Leopard)
Processor: Intel

I have a sheet (sheet1) and a pivot table (PT). I have implemented the
command line indicated in the help files as follows: <br><br>Sub pivot() <br>
Set pvtTable = Sheet1.PivotTables(PT).PivotCache.Refresh <br>
End Sub <br><br>What am I doing wrong? Thanks

First, you're trying to combine setting an object variable (pvtTable)
with refreshing the table. I can't tell exactly what you're trying to do
(for instance, what is PT?), but I'd try a variant of one of these

Public Sub PivotRefresh()
Dim PT As Long
PT = 1
Sheet1.PivotTables(PT).PivotCache.Refresh
End Sub

or

Public Sub PivotRefresh()
Dim pvtTable As PivotTable
Dim PT As Long
PT = 1
Set pvtTable = Sheet1.PivotTables(PT)
pvtTable.PivotCache.Refresh
End Sub
 
S

synergy46

Sorry for the obfuscation. PT = Name of my Pivot Table... Got it working. Thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top