[mso] Re: Macro sorting a list

Hi Mike,

You are correct - I am using XL2003

You advice appreciated. Have decided to break a complex macro into smaller 
pieces which will make debugging easier (I hope!)

I am using an InputBox, which is very useful, but do you know of a similar 
object for selection from a List?

You help much appreciated.

John
John Grierson
----- Original Message ----- 
From: "Mike Clare" <mjclare@xxxxxxxxxx>
To: <mso@xxxxxxxxxxxxx>
Sent: Saturday, December 29, 2007 1:21 AM
Subject: [mso] Re: Macro sorting a list


> John,
>
> It appears that you recorded this macro from a XL2003 or later platform.
>
> The resulting code will fail if you try to run it under an earlier
> version.  It will fail because 'DataOption1' is not a valid parameter
> for these older versions.  If this is the failure message you are seeing
> then you can edit your code to get past this problem.  All of the
> parameters to the sort method are optional and if you don't supply them
> then Excel will use default values.  Depending on your data of course...
> both of these subroutines can give you the same result:
>
> Sub main2000()
>     Range("A1").Select
>     Range("A1:C7").Sort Key1:=Range("A1")
> End Sub
> Sub main2003()
>     Range("A1").Select
>     Range("A1:C7").Sort Key1:=Range("A1"), _
>                         Order1:=xlAscending, _
>                         Header:= xlGuess, _
>                         OrderCustom:=1, _
>                         MatchCase:=False, _
>                         Orientation:=xlTopToBottom, _
>                         DataOption1:=xlSortNormal
> End Sub
>
> The 'Main2000' will work on just about any version of excel but the
> Main2003 will fail on xl2000 (and probably on xl97 too).
>
> So... did I guess correctly and identify the type of failure you are 
> seeing?
>
> Mike Clare
>
>
>
> John Grierson wrote:
>> I have written a macro that adds a new product to a list and should then 
>> sort the list.
>> The code produced by the macro recorder for clicking cell A1, then the 
>> down arrow and Sort ascending is:
>>
>>     Range("A1").Select
>>     Range("A1:C7").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= 
>> _
>>         xlGuess, OrderCustom:=1, MatchCase:=False, 
>> Orientation:=xlTopToBottom, _
>>         DataOption1:=xlSortNormal
>>
>> But this fails when the macro is run.
>>
>> Any clues, please?
>>
>> John
>>
>>
>> John Grierson
>>
>> *************************************************************
>> You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx 
>> or MicrosoftOffice@xxxxxxxxxxxxxxxx
>>
>> To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
>>
>> To Unsubscribe from this group, visit the group's homepage and use the 
>> dropdown menu at the top.  This will allow you to unsubscribe your email 
>> address or change your email settings to digest or vacation (no mail).
>> http://www.freelists.org/webpage/mso
>>
>> To be able to share files with the group, you must join our Yahoo sister 
>> group.  This group will not allow for posting of emails, but will allow 
>> you to join and share problem files, templates, etc.: 
>> http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for 
>> FILE SHARING ONLY.
>>
>> If you are using Outlook and you see a lot of unnecessary code in your 
>> email messages, read these instructions that explain why and how to fix 
>> it:
>> http://personal-computer-tutor.com/abc3/v28/greg28.htm
>> *************************************************************
>>
>>
>>
>
> *************************************************************
> You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
> MicrosoftOffice@xxxxxxxxxxxxxxxx
>
> To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
>
> To Unsubscribe from this group, visit the group's homepage and use the 
> dropdown menu at the top.  This will allow you to unsubscribe your email 
> address or change your email settings to digest or vacation (no mail).
> http://www.freelists.org/webpage/mso
>
> To be able to share files with the group, you must join our Yahoo sister 
> group.  This group will not allow for posting of emails, but will allow 
> you to join and share problem files, templates, etc.: 
> http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for 
> FILE SHARING ONLY.
>
> If you are using Outlook and you see a lot of unnecessary code in your 
> email messages, read these instructions that explain why and how to fix 
> it:
> http://personal-computer-tutor.com/abc3/v28/greg28.htm
> ************************************************************* 

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, visit the group's homepage and use the dropdown 
menu at the top.  This will allow you to unsubscribe your email address or 
change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso

To be able to share files with the group, you must join our Yahoo sister group. 
 This group will not allow for posting of emails, but will allow you to join 
and share problem files, templates, etc.:  
http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for FILE 
SHARING ONLY.

If you are using Outlook and you see a lot of unnecessary code in your email 
messages, read these instructions that explain why and how to fix it:
http://personal-computer-tutor.com/abc3/v28/greg28.htm
*************************************************************

Other related posts: