I recorded a macro to create a pivot table based on data in the sheet "Data." The problem is I'm not sure how to create a new sheet for the pivot table (Sheets.Add) and then immediately give it a name, since if I run this over and over I have to keep changing "SheetX" to "SheetX+1" and so on.
Sheets("Data").Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Feb Data!R1C1:R3000C150", Version:=6).CreatePivotTable TableDestination:= _
"Sheet9!R3C1", TableName:="PivotTable1", DefaultVersion:=6
Sheets("Sheet9").Select
Sheets("The name of the shee").Name = "The name you want"
– Damianws = application.thisworkbook.sheets.add
and then ws will be dynamic andws.name
will work like damian suggested. You can then just have an integer counter if you need the name to be unique and you intend to store all previous outputs. – SadMrFrown