thelostscott
Board Regular
- Joined
- May 7, 2010
- Messages
- 226
Hi all,
I'm having an issue trying to create a Pivot Table in VBA. How do I get the red section of the code below to reflect a changing array, not a set array as it is showing?
I want to be able to use this Macro in other workbooks where the Source Data will change.
Thanks
I'm having an issue trying to create a Pivot Table in VBA. How do I get the red section of the code below to reflect a changing array, not a set array as it is showing?
I want to be able to use this Macro in other workbooks where the Source Data will change.
Code:
Sheets("SOURCE").Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Sheets.Add
[COLOR=Black]ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, [COLOR=Red]SourceData:="SOURCE!R1C1:R26523C46"[/COLOR] Version:=xlPivotTableVersion12).CreatePivotTable TableDestination:="Sheet2!R3C1", TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion12[/COLOR]