I have a macro part that would copy a sheet with a pivot table from another file to another and change the data range to the one already indicated in the target file. However, when I try, I get two errors once "Subscript out of range" or "Invalid Procedure Call Or Argument Error"
wbStart is a file where there is only a button to start a macro and one tab to be move,
My code:
wbStart is a file where there is only a button to start a macro and one tab to be move,
My code:
VBA Code:
Set wb = Workbooks.Open(MyFolder & "\" & MyFile, UpdateLinks:=0)
Set wbStart = ThisWorkbook
wbStart.Sheets("Tabela_COREP").Copy After:=wbMe.Sheets(1)
wb.Sheets("Tabela_COREP").PivotTables("Tabela przestawna1").ChangePivotCache wb.Sheets("Tabela_COREP"). _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:="corep", Version:=6)
'Usuwamy alerty o akutliazacji itp'