View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
bruce taylor[_2_] bruce taylor[_2_] is offline
external usenet poster
 
Posts: 1
Default HELP! Code for Pivot Table

I had the same need.
Found the only reliable way was to remove the existing
pivot table (by deleting all the rows). Then apply code
to create a new pivot table from scratch. It is always
PivotTable1.
You can also do interesting sorting and formatting in
column headers (at the very least).
-----Original Message-----
Sub TestRefresh()
Dim pvt As PivotTable
For Each pvt In ActiveSheet.PivotTables
MsgBox pvt.Name
pvt.RefreshTable
Next


End Sub

--
Regards,
Tom Ogilvy



Sandy wrote in message
...
Hello!

Hope someone out there can help me. I need to update

or
refresh a Pivot Table in code. Here's the scenario:

I am importing from an Access DB to Columns A through

H in
Excel. That spreadsheet has a Pivot Table at K4

through
Q33.

I tried recording a macro to get the language, but it

just
ignores it's own language when I put it
in "Worksheet_Activate" in Excel. I did notice,

however,
that on two different occasions, it referred to the

Pivot
Table as PivotTable2 and PivotTable4. I don't know

where
it gets that name from. Is there any way of looking

this
up? And why does it change? Why didn't it start with
PivotTable1, since it's the only Pivot Table in the
spreadsheet?

At any rate, I would rather, if possible, just put the
language in Access, but if I can't even get the correct
language for Excel . . .

Sandy



.