Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying Pivot help !!


Hi,

I've recorded adding one pivot table and then copying it 4 times and
changing some info.

The code below remembers the old Pivot Table no 11. How do I get it to
use the next un-used Pivot table no ??

ActiveSheet.PivotTables("PivotTable11").PivotField s("Source").CurrentPage
= _
"P. YR"

Any help appreciated

VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=569783

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Copying Pivot help !!

You can use variables to identify each pivot table as you create it. For
example:

'=============================
Sub CopyPivot()
Dim ws1 As Worksheet
Dim pc As PivotCache
Dim pt1 As PivotTable
Dim pt2 As PivotTable

Set ws1 = Worksheets("Sheet1")
Set pc = ActiveWorkbook.PivotCaches.Add(xlDatabase, _
SourceData:="PivotData")
Set pt1 = pc.CreatePivotTable(TableDestination:=ws1.Range("A 3"), _
TableName:="SalesPivot1")

With pt1
.AddFields RowFields:="Region"
.PivotFields("Units").Orientation = xlDataField
With .PivotFields("Item")
.Orientation = xlPageField
.Position = 1
End With
End With

pt1.TableRange2.Copy Destination:=ws1.Range("F1")
Set pt2 = ws1.Range("F1").PivotTable
pt2.PivotFields("Item").CurrentPage = "Desk"

End Sub
'==============================

VBA Noob wrote:
Hi,

I've recorded adding one pivot table and then copying it 4 times and
changing some info.

The code below remembers the old Pivot Table no 11. How do I get it to
use the next un-used Pivot table no ??

ActiveSheet.PivotTables("PivotTable11").PivotField s("Source").CurrentPage
= _
"P. YR"

Any help appreciated

VBA Noob




--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copying Pivot help !!


Thanks Debra

VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=569783

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
Copying pivot table Nadine Excel Discussion (Misc queries) 2 February 11th 08 03:13 PM
Copying values from pivot table to cells outside pivot table richzip Excel Discussion (Misc queries) 4 January 16th 08 11:03 PM
Copying Pivot tables (How to) Lebowski Excel Discussion (Misc queries) 1 May 28th 07 12:21 PM
copying subtotals in Pivot tables Tab Excel Worksheet Functions 3 June 23rd 05 09:11 PM
Copying sheets with pivot tables mnirula Excel Worksheet Functions 0 March 1st 05 01:47 AM


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