I have a macro that creates a pivot table with the data from a sheet titled “IBC”. How do I get the macro to create the pivot table from any sheet, not just the one titled “IBC”
I know this code is specifying that pivot table should use Source data from the table "IBC" but how do I get the pivot table to pull from the table/sheet I'm actively viewing, not just "IBC"?
Application.CutCopyMode = False
Sheets.Add
pivotws = ActiveSheet.Name
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="IBC", Version:=7).CreatePivotTable TableDestination:=pivotws & "!R3C1", TableName:="PivotTable3", DefaultVersion:=7
Sheets(pivotws).Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable3")