Thanks Tom,
I did that originally and I walked through debugging my steps and found the
pivot table getting created in the same sheet as my data. I selected "new
sheet" when I went through the macro creator. I just can't figure out now
what to change to have it insert a new sheet, hence my questioin.
I get lines like this from the macro recorder:
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Data!R1C1:R3703C62").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
It seems that setting the TableDestination argument (of the CreatePivotTable
method of the PivotCache object) to an empty string causes it to create a
new sheet.
However, I would create the sheet myself if I was doing it in code
Dim sh As Worksheet
Set sh = ActiveWorkbook.Sheets.Add
wb.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"MyRangeName").CreatePivotTable TableDestination:=sh.Cells(3, 1),
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10