I'm trying to be able to use this macro to create this pivot table each day on the same worksheet name. The only thing that will change is the datasource row as I never know how many rows it will be. I tried to set the entire string into the CurSourceData variable and then just use that but it fails and says invalid arg.
Any ideas would be helpful.
Sheets("Cases 23+ Day (Due Today)").Select Range("A1").Select Selection.End(xlDown).Select Selection.End(xlDown).Select CurRow = ActiveCell.Row CurSourceData = "Cases 23+ Day (Due today)!R1C2:R" & CurRow & "C20" ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ CurSourceData, Version:=xlPivotTableVersion14). _ CreatePivotTable TableDestination:="Master Summary!R3C7", TableName:= _ "PivotTable3", DefaultVersion:=xlPivotTableVersion14 Sheets("Master Summary").Select Cells(3, 7).Select ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _ "PivotTable3").PivotFields("Status"), "Count of Status", xlCount With ActiveSheet.PivotTables("PivotTable3").PivotFields("Status") .Orientation = xlRowField .Position = 1 End With