I am trying to write a macro to create a pivot table in a new sheet. I'm having problems eliminating the dependence on sheet names, as the names of my data changed daily, but the format does not.
My macro errors here with "Run-time error 438: Object doesn't support this property of method"
'create pivot table
Range("A1:J25").Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
ActiveSheet.Last & "!R1C1:R25C10", Version:=xlPivotTableVersion14 _
).CreatePivotTable TableDestination:="Sheet1!R3C1", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion14
What can I replace "sheetx!R1C1:R25C10" with that doesn't rely on a name?