Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Help with Pivot Table "BaseItem"

Does anyone know of a way to select the "last" BaseItem in a pivot table. I
used the recorder and got this far.

I have a named range "Database" that uses CountA to determine the last
entry. The data comes from an export. The export will vary, but I will
always want to select the calculation on the pivot table to "PercentOf" and
will want the last entry to be the "BaseItem". Also if someone knows a
cleaner way to write what the recorder produced I would appreciate them
suggesting changes. I added the first line so that I could run the macro
from any worksheet.

I have been working on this project off and on for about a year now and have
gotten good feedback from the group.

Thanks,
Joel





Sub CummulativePivot()

Worksheets("Data").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Database").CreatePivotTable TableDestination:="",
TableName:="PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Data", _
ColumnFields:="Week Ending"
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Early" &
Chr(10) & "% Comp.")
.Orientation = xlDataField
.Position = 1
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Late" &
Chr(10) & "% Comp.")
.Orientation = xlDataField
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Help with Pivot Table "BaseItem"

I guess the pivot table baseitem can't be selected using VBA.



"Joel Mills" wrote in message
...

Does anyone know of a way to select the "last" BaseItem in a pivot table.
I used the recorder and got this far.

I have a named range "Database" that uses CountA to determine the last
entry. The data comes from an export. The export will vary, but I will
always want to select the calculation on the pivot table to "PercentOf"
and will want the last entry to be the "BaseItem". Also if someone knows
a cleaner way to write what the recorder produced I would appreciate them
suggesting changes. I added the first line so that I could run the macro
from any worksheet.

I have been working on this project off and on for about a year now and
have gotten good feedback from the group.

Thanks,
Joel





Sub CummulativePivot()

Worksheets("Data").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Database").CreatePivotTable TableDestination:="",
TableName:="PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Data", _
ColumnFields:="Week Ending"
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Early"
& Chr(10) & "% Comp.")
.Orientation = xlDataField
.Position = 1
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Late" &
Chr(10) & "% Comp.")
.Orientation = xlDataField
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Help with Pivot Table "BaseItem"

If you're trying to use the last entry in the pivot data source as the
base item, you could use code similar to the following, where the Week
Ending field is in column A:

Dim strLastItem
Dim rngPivotData As Range
Set rngPivotData = Sheets("Data").Range("Database")
strLastItem = rngPivotData.Cells(rngPivotData.Rows.Count, 1).Value

With ActiveSheet.PivotTables(1).PivotFields("Target Early")
.BaseField = "Week Ending"
.BaseItem = strLastItem
End With


Joel Mills wrote:
I guess the pivot table baseitem can't be selected using VBA.



"Joel Mills" wrote in message
...


Does anyone know of a way to select the "last" BaseItem in a pivot table.
I used the recorder and got this far.

I have a named range "Database" that uses CountA to determine the last
entry. The data comes from an export. The export will vary, but I will
always want to select the calculation on the pivot table to "PercentOf"
and will want the last entry to be the "BaseItem". Also if someone knows
a cleaner way to write what the recorder produced I would appreciate them
suggesting changes. I added the first line so that I could run the macro
from any worksheet.

I have been working on this project off and on for about a year now and
have gotten good feedback from the group.

Thanks,
Joel





Sub CummulativePivot()

Worksheets("Data").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Database").CreatePivotTable TableDestination:="",
TableName:="PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Data", _
ColumnFields:="Week Ending"
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Early"
& Chr(10) & "% Comp.")
.Orientation = xlDataField
.Position = 1
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Late" &
Chr(10) & "% Comp.")
.Orientation = xlDataField
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
End Sub






--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Help with Pivot Table "BaseItem"

Thanks, Debra that's what I wanted to do.


"Debra Dalgleish" wrote in message
...
If you're trying to use the last entry in the pivot data source as the
base item, you could use code similar to the following, where the Week
Ending field is in column A:

Dim strLastItem
Dim rngPivotData As Range
Set rngPivotData = Sheets("Data").Range("Database")
strLastItem = rngPivotData.Cells(rngPivotData.Rows.Count, 1).Value

With ActiveSheet.PivotTables(1).PivotFields("Target Early")
.BaseField = "Week Ending"
.BaseItem = strLastItem
End With


Joel Mills wrote:
I guess the pivot table baseitem can't be selected using VBA.



"Joel Mills" wrote in message
...


Does anyone know of a way to select the "last" BaseItem in a pivot table.
I used the recorder and got this far.

I have a named range "Database" that uses CountA to determine the last
entry. The data comes from an export. The export will vary, but I will
always want to select the calculation on the pivot table to "PercentOf"
and will want the last entry to be the "BaseItem". Also if someone knows
a cleaner way to write what the recorder produced I would appreciate them
suggesting changes. I added the first line so that I could run the macro
from any worksheet.

I have been working on this project off and on for about a year now and
have gotten good feedback from the group.

Thanks,
Joel





Sub CummulativePivot()

Worksheets("Data").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Database").CreatePivotTable TableDestination:="",
TableName:="PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Data", _
ColumnFields:="Week Ending"
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Early"
& Chr(10) & "% Comp.")
.Orientation = xlDataField
.Position = 1
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Target Late"
& Chr(10) & "% Comp.")
.Orientation = xlDataField
.Calculation = xlPercentOf
.BaseField = "Week Ending"
.BaseItem = "26-Sep-04"
End With
End Sub






--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



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
Create Pivot Table Data with Column "Sum" rather than "count" defa Johnny_99[_2_] Excel Discussion (Misc queries) 2 January 2nd 10 03:25 PM
Pivot Table Report Filter - "OR" instead of "AND" Multiple Filters tommcbrny Excel Discussion (Misc queries) 1 October 29th 09 03:08 AM
Keep a column of comments "with" pivot table as pivot tables datachanges, causing rows to be added and deleted. Tim Richardson Excel Discussion (Misc queries) 0 August 31st 09 02:53 AM
OfficeXP "Cannot open pivot table source file" when refreshing pivot table Luc Alquier Excel Programming 2 December 9th 03 11:11 PM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana[_5_] Excel Programming 0 August 21st 03 10:19 PM


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

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"