Hello!
How would I edit this code to reference a dynamic range instead of a specific table? I tried modifying what Record Macro gave me, but did not have any success.
Any assistance would be greatly appreciated!
How would I edit this code to reference a dynamic range instead of a specific table? I tried modifying what Record Macro gave me, but did not have any success.
Any assistance would be greatly appreciated!
Code:
Sheets.Add
ActiveSheet.Name = "In Program Pivot"
[COLOR=#008000]Dim tri As Long[/COLOR]
[COLOR=#008000]tri = Sheets("In Program").Select.Range("A1:O" & Range("O" & Rows.Count).End(xlUp).Row)[/COLOR]
Sheets("In Program Pivot").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, [COLOR=#008000]SourceData:= _[/COLOR]
[COLOR=#008000] "tri"[/COLOR], Version:=xlPivotTableVersion15).CreatePivotTable TableDestination _
:="'In Program Pivot'!R3C1", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion15
Sheets("In Program Pivot").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Member Name")
.Orientation = xlRowField
.Position = 1
End With