ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code not working in Excel 2007 (https://www.excelbanter.com/excel-programming/430203-code-not-working-excel-2007-a.html)

abajo

Code not working in Excel 2007
 

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,

Patrick Molloy

Code not working in Excel 2007
 

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'





"abajo" wrote in message
...
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,




All times are GMT +1. The time now is 02:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com