Hello guys, I have a problem because I wanted to create a PivotTable with a macro where the rows will be RES_MAT and the values will be WYCENA_PLNL. However, I did it with macro recording and I'm afraid it will crash to me at some point, how do I modify it to correct VBA code. And how to make it create a table, e.g. in a new sheet ? Thanks !
VBA Code:
wbMe.Sheets("papiery").Activate
wbMe.Sheets("papiery").Range("D1:L1" & Columns.Count).End(xlDown).Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"papiery!R1C4:R30C12", Version:=6).CreatePivotTable TableDestination:= _
"papiery!R28C16", TableName:="Tabela przestawna3", DefaultVersion:=6
wbMe.Sheets("papiery").Select
Cells(28, 16).Select
With wbMe.Sheets("papiery").PivotTables("Tabela przestawna3").PivotFields("RES_MAT")
.Orientation = xlRowField
.Position = 1
End With
wbMe.Sheets("papiery").PivotTables("Tabela przestawna3").AddDataField ActiveSheet. _
PivotTables("Tabela przestawna3").PivotFields("WYCENA_PLN"), _
"Suma z WYCENA_PLN", xlSum