I have written a macro, changept, to restructure a pivot table. The macro works when I run it directly from excel(tools> macro, etc) but when I create a button and call changept within the event code I get an error message. Why? Is this just (yet) another example of VBA not handling pivot tables very well or am I doing this the wrong way?
I'm including the code for completeness below but this question is more about the difference between running code from a button and running it directly.
Thanks in advance
ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:= _
"Selected Price Bands EU", ColumnFields:="Month ", PageFields:=Array( _
"Page Size", "Print Speed Colour", "Mono Speed Band", "Long Product Name", _
"Memory - RAM (MB)", "Print Speed Black (ppm)", "Vendor ", _
"Channel ", "Mono or Colour")
Private Sub CommandButton3_Click()