C
Charles L. Snyder
Hi
An easy question:
With this code to create a pivot table:
Sub pt()
Dim LastRow As Long
Dim LastColumn As Long
LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).Row
LastColumn = Cells.Find(What:="*", After:=[A1],
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
Sheets.Add.Name = "pivot"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,
SourceData:= _
"cases-dump!R1C1:R3857C14",
Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="pivot!R3C1", TableName:="PivotTable1",
DefaultVersion _
:=xlPivotTableVersion12
Sheets("pivot").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Procedure
Date")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField
ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("rvu"), "Sum of rvu", xlSum
Range("A6").Select
Selection.Group Start:=True, End:=True, Periods:=Array(False,
False, False, _
False, True, False, True)
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Years")
.Orientation = xlColumnField
.Position = 1
End With
End Sub
what is the correct syntax to replace:
SourceData:= _
"cases-dump!R1C1:R3857C14"
with
SourceData:= _
"cases-dump!R1C1:R [LastRowcd ] C [Last Column]"
I copied the code from the macro editor, and altered it a little, but
need the correct R1C1 notation to use the last row and column in the
(variable) source data.
Thanks!
Charles Snyder
An easy question:
With this code to create a pivot table:
Sub pt()
Dim LastRow As Long
Dim LastColumn As Long
LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).Row
LastColumn = Cells.Find(What:="*", After:=[A1],
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
Sheets.Add.Name = "pivot"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,
SourceData:= _
"cases-dump!R1C1:R3857C14",
Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="pivot!R3C1", TableName:="PivotTable1",
DefaultVersion _
:=xlPivotTableVersion12
Sheets("pivot").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Procedure
Date")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField
ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("rvu"), "Sum of rvu", xlSum
Range("A6").Select
Selection.Group Start:=True, End:=True, Periods:=Array(False,
False, False, _
False, True, False, True)
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Years")
.Orientation = xlColumnField
.Position = 1
End With
End Sub
what is the correct syntax to replace:
SourceData:= _
"cases-dump!R1C1:R3857C14"
with
SourceData:= _
"cases-dump!R1C1:R [LastRowcd ] C [Last Column]"
I copied the code from the macro editor, and altered it a little, but
need the correct R1C1 notation to use the last row and column in the
(variable) source data.
Thanks!
Charles Snyder