I have two workbooks; in one I have a Pivot table; in the other, an empty worksheet.
I am trying to copy certain data from the pivot table to the other workbook, but it seems like VBA isnt copying my selection.
Currently I have written:
With cevesa.Worksheets("r_hora")
On Error Resume Next
.PivotTables("r_hora").PivotFields("PARAM").ClearAllFilters
.PivotTables("r_hora").PivotSelection = "PARAM['DEM(MW)':'DEM_AGREGADA(MW)','POT(MW)':'POT_HID(MW)','POTDESP(MW)']"
Selection.Copy
analisis.Worksheets("DATOS Generación").Range("B1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
On error goto 0
End with
However, this wont work unless I activate manually the workbook with the Pivot table. It seems to me the selection.copy line is working only for the active workbook, and not pointing at the current Pivotselection.
Thanks!
cevesa.Activate
andcevesa.Worksheets("r_hora").Activate
– Slai