1

how would I make this piece of code dynamic so the rows and columns so the code would continue to work even for different data sets.

Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:**R5000C200**", Version:=6).CreatePivotTable TableDestination:= _
"Sheet2!R3C1", TableName:="PivotTable1", DefaultVersion:=6
BigBen
  • 46,229
  • 7
  • 24
  • 40
  • Make your source data a table (`ListObjeect`) first. – BigBen Nov 04 '21 at 16:19
  • Or [find the last row](https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-excel-with-vba). And similarly find that last column. – BigBen Nov 04 '21 at 16:20

0 Answers0