PC Review


Reply
Thread Tools Rate Thread

Code not working in Excel 2007

 
 
abajo
Guest
Posts: n/a
 
      23rd Jun 2009

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,
 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      23rd Jun 2009

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" <(E-Mail Removed)> wrote in message
news:6D3800E1-12A2-45F4-8928-(E-Mail Removed)...
> 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,


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 sorting ribbon is not working with .Net save code Yihong Microsoft Excel Programming 0 25th May 2010 09:43 PM
Simple VBA Code Working in Excel 2007 but not Excel 2003 #N/A KMH Microsoft Excel Programming 1 3rd Mar 2010 09:25 AM
2003 Code Not Working in 2007 CJ Microsoft Access Form Coding 6 31st Oct 2008 09:54 PM
Excel 2007 Macro Help (Excel 2003 not working in 2007) Pman Microsoft Excel Misc 4 29th May 2008 06:29 PM
Code not working since upgrade to 2007 Terry K Microsoft Excel Programming 2 4th Jan 2008 07:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 AM.