pivot table macro error

Occasional Contributor


Whats is wrong with the "end of statement"? 


pivot table macro errorpivot table macro error

8 Replies

Does it help if you use

        :="'" & pivotWS & "'!R3C1", ...

@Hans Vogelaar 


hi. have got this new error


pivot table macro error3.PNG




What is the error message?

It might help if you attached a copy of the workbook, or uploaded it to a cloud service such as OneDrive, google Drive or Dropbox, obtained a link to the uploaded file and posted that link in a reply.


When I click that link, I get "You need access"...

best response confirmed by annapet1973 (Occasional Contributor)


Thanks, that worked. Use

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "'08.04.2022'!R1C1:R19C9", Version:=6).CreatePivotTable TableDestination:= _
        pivotWB & "!R3C1", TableName:="PivotTable1", DefaultVersion:=6
Thanks!!! It works now