Hello All,
I have recorded a macro to create a pivot table but I get an run-time error '5' when I run the macro. the bit of code that's causing the issue is here
First question is how to make the macro work each time and second question is how to ensure that all rows containing data is selected? in the code above the source data is set at R1C1 to R13C5. I will be having more or less number of rows depending upon the actual use case.![]()
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _ "Pivot Table!R1C1:R13C5", Version:=xlPivotTableVersion14).CreatePivotTable _ TableDestination:="Pivot Table!R5C9", TableName:="PivotTable4", _ DefaultVersion:=xlPivotTableVersion14
Thanks,
Aadesh
Bookmarks