Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Using VBA to rename Pivot Table Query

(Dave This is copied from response I made to your earlier
reply to my query of yesterday I am reposting it here so
that others may have opportunity to help me further, as I
have doubts that many of them are likkely to gpo as far as
a second level expansion to look for a question to answer)

Dave,

Thanks so very very much for your response. I think it
gets close to what I'm after, however perhaps I'm still
doing something not quite right as when I run this
procedure my PivotTable1 has its name changed to
PivotTable_2, rather than the copy. And even if I change
PivotTable1's name to PivotTable_Base it still changes
it's rather than the new table's name to PivotTable_2.

I would appreciate any further thoughts from you or others.

Many thanks again for your response.
Ron
-----Original Message-----
This seemed to work ok for me:

Option Explicit
Sub testme()

With ActiveSheet
.PivotTables("PivotTable1").PivotSelect "",

xlDataAndLabel
Selection.Copy
Application.Goto Reference:="Target_Region"
End With

With ActiveSheet
.Paste
Application.CutCopyMode = False
.PivotTables(.PivotTables.Count).Name

= "PivotTable_2"
End With

End Sub

The last pivottable added is .pivottables.count.



Ron McCormick wrote:

I wish to copy a pivot table report and name
it "PivotTable_2". How do I do this programmatically?

I
tried recording a macro and came up with the following:

ActiveSheet.PivotTables("PivotTable1").PivotSelect "",
xlDataAndLabel
Selection.Copy
Application.Goto Reference:="Target_Region"
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.PivotTables("PivotTable8").Name
= "PivotTable_2"

The problem is that next time I run the procedure the
Pivot Table to be named "PivotTable_2" is "PivotTable9".
How do I get the table to be "PivotTable8" each time?

(If
I knew that I wouldn't actually need to rename it
as "PivotTable_2"!).

TIA
Ron


--

Dave Peterson


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
How to rename a GROUP in a Pivot table spudsnruf Charts and Charting in Excel 6 April 4th 23 10:25 AM
How do you rename table headers in a query using Offic 07? DFoster Excel Worksheet Functions 3 August 29th 08 01:48 PM
Need to rename table columns in excel from a query DFoster Excel Worksheet Functions 3 August 26th 08 10:24 PM
rename groups in Pivot table Kermit Excel Discussion (Misc queries) 1 July 8th 08 08:50 AM
Using VBA to rename Pivot Table Query Ron McCormick[_3_] Excel Programming 3 November 7th 03 03:28 AM


All times are GMT +1. The time now is 05:53 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"