Greetings,
I am able to create a pivot table with a recorded macro but I do not know how to edit the code so that it automatically adjusts to the data range size as it varies from one sheet to another. Below I'm posting the part of the manually recorded VBA that "I think" establishes the initial data range and I'm hoping someone can tell me how to edit it to work as needed. Thank you.
'Sub Pivot()
'
' Pivot Macro
'
' Keyboard Shortcut: Ctrl+w
'
' Sheets.Add
' ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
' "Export (9)!R1C1:R172C7", Version:=6).CreatePivotTable TableDestination:= _
' "Sheet1!R3C1", TableName:="PivotTable1", DefaultVersion:=6
' Sheets("Sheet1").Select
' Cells(3, 1).Select
' With ActiveSheet.PivotTables("PivotTable1")
I am able to create a pivot table with a recorded macro but I do not know how to edit the code so that it automatically adjusts to the data range size as it varies from one sheet to another. Below I'm posting the part of the manually recorded VBA that "I think" establishes the initial data range and I'm hoping someone can tell me how to edit it to work as needed. Thank you.
'Sub Pivot()
'
' Pivot Macro
'
' Keyboard Shortcut: Ctrl+w
'
' Sheets.Add
' ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
' "Export (9)!R1C1:R172C7", Version:=6).CreatePivotTable TableDestination:= _
' "Sheet1!R3C1", TableName:="PivotTable1", DefaultVersion:=6
' Sheets("Sheet1").Select
' Cells(3, 1).Select
' With ActiveSheet.PivotTables("PivotTable1")