ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selecting variable rows in a macro that creates a pivot table (https://www.excelbanter.com/excel-programming/329240-selecting-variable-rows-macro-creates-pivot-table.html)

amarch00

selecting variable rows in a macro that creates a pivot table
 

I'm trying to create a multi-consolidation range pivot table via
macro. Each time I run the macro the number of rows will be different
The macro is currently hardcoding the source data into a fixed rang
for column and row. See below.

How do I change this to allow for a variable row selection?

ActiveWorkbook.PivotCaches.Add(SourceType:=xlConso lidation
SourceData:= _
Array("'EAG Original'!R1C2:R82C6")).CreatePivotTabl
TableDestination:="", _
TableName:="PivotTable15

--
amarch0
-----------------------------------------------------------------------
amarch00's Profile: http://www.officehelp.in/member.php?userid=1
View this thread: http://www.officehelp.in/showthread.php?t=63290
Visit - http://www.officehelp.in/archive/index.php


Debra Dalgleish

selecting variable rows in a macro that creates a pivot table
 
You could use a dynamic range as the pivot source, and refer to the
range name in the code. There are instructions he

http://www.contextures.com/xlPivot01.html


amarch00 wrote:
I'm trying to create a multi-consolidation range pivot table via a
macro. Each time I run the macro the number of rows will be different.
The macro is currently hardcoding the source data into a fixed range
for column and row. See below.

How do I change this to allow for a variable row selection?

ActiveWorkbook.PivotCaches.Add(SourceType:=xlConso lidation,
SourceData:= _
Array("'EAG Original'!R1C2:R82C6")).CreatePivotTable
TableDestination:="", _
TableName:="PivotTable15"




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



All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com