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: 18
Default Adding Data Fields to Pivot Tables

My data source has months as headers with dollar amounts below. When I
add a new month to data source and delete the oldest month I want to
be able to add the new month to the pivot table. I think I can do this
by making the header a variable in VBA. Here is what I have:

Sub InsertNewMonth()

Dim Month14
Set Month14 = Worksheets("Detail").Range("Y3")

' I got this from the macro recorder
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Jun-09")
.Orientation = xlDataField
.Caption = "Sum of " & Month14
.Position = 14
.Function = xlSum
End With
ActiveSheet.PivotTables("PivotTable1").DataPivotFi eld.PivotItems( _
"Sum of Jun-09").Position = 14

End Sub

I want to be able to take the variable Month14 and insert it into the
pivot table in position 14 as a sum.

Thanks for your help.
 
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
Default calculation for data fields in Pivot Tables? KDJ Excel Discussion (Misc queries) 1 September 9th 09 07:37 AM
Pivot tables: disappearing data fields the1859 Excel Discussion (Misc queries) 2 September 16th 08 03:41 PM
Are there defaults for data fields in pivot tables (sum or count) willyindel Excel Worksheet Functions 0 February 22nd 08 10:00 PM
Grouping Data fields in Pivot Tables. [email protected] Excel Discussion (Misc queries) 2 April 8th 07 12:05 PM
Pivot Tables multiple data fields Excel GuRu Excel Worksheet Functions 2 December 16th 04 12:06 AM


All times are GMT +1. The time now is 06:18 AM.

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"