Hi. My code to create a pivot table was captured using the marco recorder. This specifies the source data as "CDRACBS!R2C1:R2804C9". However, this no longer works as it should because the source data continues to increase in size - specifically more rows are added to the source data. How do I write the code for this? Is it just a matter of always finding the last used row in the source data? The relevant part of the code is below. Thank you.
VBA Code:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"CDRACBS!R2C1:R2804C9", Version:=6).CreatePivotTable TableDestination:= _
"Suppliers!R3C1", TableName:="PivotTable1", DefaultVersion:=6