LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Pivot table code question

Hi, I'm in Excel 2010 and using the code below to do some pivot table
work. In several of the lines of code the pivot table is identified as
PivotTable6. This worries me because I want it to be able to run on
Pivot tables of the future that will most likely not have that name.
Is there a way that I can modify this code to have it identify the
pivot table correctly without actually using its name? Many thanks.



Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDa tabase,
SourceData:= _
"My Calcs!R1C1:R109C23",
Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:="Sheet1!R3C1", TableName:="PivotTable6",
DefaultVersion _
:=xlPivotTableVersion10
Sheets("Sheet1").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable6").PivotFields ("Mgr E-
mail")
.Orientation = xlRowField
.Position = 1
End With
Range("A9").Select
With ActiveSheet.PivotTables("PivotTable6")
.ColumnGrand = False
.RowGrand = False
End With
Range("A6").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

MsgBox "The Macro is paused until you paste the email addresses in
an Outlook email. Click OK when complete"
 
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
Code that will rerun or refresh a pivot table (after new data ispasted into the original Pivot Table's Source Range) Mike C[_5_] Excel Programming 3 February 15th 08 06:22 AM
Code for a Macro that allows a Pivot table to be repeatedly run (fora dynamic rows in a table, but static field names) Mike C[_5_] Excel Programming 1 February 11th 08 04:30 AM
Pivot Table Question: SubTotals for 2 of 4 Pivot Tables in same worksheet [email protected] Excel Programming 0 December 19th 06 05:13 PM
Pivot Table Question : If statment in Pivot Table?? seve Excel Discussion (Misc queries) 2 November 22nd 05 01:00 AM
VBA Code for a pivot table to open database and to reference table current page Pete Straman Straman via OfficeKB.com Excel Programming 0 February 21st 05 03:57 AM


All times are GMT +1. The time now is 09:49 PM.

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

About Us

"It's about Microsoft Excel"