Code not working in Excel 2007

A

abajo

Any Idea why the following macro code returns this error:
"Run-time error '1004': Sort Method of Range Class failed". The code works
fine in Office Excel 2003.

ActiveSheet.PivotTables(pivName).PivotSelect "month[All]", xlLabelOnly
Selection.Sort Order1:=xlAscending, Type:=xlSortLabels,
OrderCustom:=csort, Orientation:=xlTopToBottom

Thanks,
 
P

Patrick Molloy

to check this i added

dim target as range
set target = selecttion

and in your code replaced Selection by target so the line that starts
Selection.Sort
became
target.Sort

my demo file worked for both versions of Excel.

in my demo, the selected cell was the row label 'Month'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top