Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default HELP! Code for Pivot Table

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default HELP! Code for Pivot Table

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default HELP! Code for Pivot Table

Thanks!
-----Original Message-----
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



.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default HELP! Code for Pivot Table

Thanks, Myrna!
-----Original Message-----
On Tue, 2 Sep 2003 18:57:59 -0700, "Sandy"

wrote:

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.


Each time you create a new table, it's assigned the next

name in sequence, even though you've
deleted the prior table(s).

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default HELP! Code for Pivot Table

Thanks, Tom!
-----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



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default HELP! Code for Pivot Table

If you want to change the name of the pivot table, you can right click
on it, and then choose options. A screen will appear, with a field
called name, that you can change.

Sandy, if you want to update your pivot table whenever you change your
data, put the following code at worksheet_change:

activesheet.pivotables("PivotTable1").refreshtable

where PivotTable1 is the name you chose to your pivot table.


"Sandy" wrote in message ...
Thanks, Tom!
-----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



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table Page Change Code PFLY Excel Discussion (Misc queries) 1 May 16th 08 12:42 AM
VBA code to refresh Child Pivot Table HKS Excel Discussion (Misc queries) 0 May 7th 08 07:49 PM
Excel Pivot Table VB Code carolini Excel Discussion (Misc queries) 1 February 6th 06 09:33 PM
Pivot Table Code FA Excel Discussion (Misc queries) 6 October 11th 05 04:03 PM
Pivot Table VBA code to move a row uclawarren Excel Discussion (Misc queries) 0 October 10th 05 08:49 PM


All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"