PC Review


Reply
Thread Tools Rate Thread

Adding Data Fields to Pivot Tables

 
 
Shane
Guest
Posts: n/a
 
      1st Jul 2008
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").DataPivotField.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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot tables: disappearing data fields the1859 Microsoft Excel Misc 1 16th Sep 2008 03:41 PM
Pivot Table Data Adding contents of two pivot tables and param que =?Utf-8?B?Um91bmR5?= Microsoft Excel Misc 0 2nd Jul 2007 10:20 PM
Grouping Data fields in Pivot Tables. rttaksali@gmail.com Microsoft Excel Misc 2 8th Apr 2007 12:05 PM
Pivot Tables multiple data fields =?Utf-8?B?RXhjZWwgR3VSdQ==?= Microsoft Excel Worksheet Functions 2 16th Dec 2004 12:06 AM
Pivot tables - adding data =?Utf-8?B?YW5hbGVh?= Microsoft Excel Misc 2 8th Jun 2004 11:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:50 AM.