[mso] Re: Macro sorting a list

The term "macro" is a bit misleading, these days.  What you record as a 
macro becomes a VBA subroutine.  Subroutines can be exceedingly complex - 
far more than you can reasonably get to with the recorder - so there's no 
need to simplify for Excel's benefit.

I think you need to post the whole of the VBA subroutine - it looks as 
though you're possibly losing track of your active sheet.  In that case, the 
Range calls could fail.

You also need to indicate how you are running the code - e.g. via a button.

Regards, Dave S

----- Original Message ----- 
From: "John Grierson" <griersoft@xxxxxxxxxxxx>
To: <mso@xxxxxxxxxxxxx>
Sent: Saturday, December 29, 2007 6:17 PM
Subject: [mso] Re: Macro sorting a list


> Thanks, Dave
>
> Sorry for the delay in replying.
>
> The error is 1004, Application-defined or Object-defined error
>
> However, I believe I am making making a single macro too complex and will
> therefore break it down into smaller pieces
>
> John
> John Grierson
> ----- Original Message ----- 
> From: "David Smart" <smartware@xxxxxxxxxxxxxxx>
> To: <mso@xxxxxxxxxxxxx>
> Sent: Thursday, December 27, 2007 10:46 PM
> Subject: [mso] Re: Macro sorting a list
>
>
>> In what way does it fail?  It works fine on my (empty) sheet in Excel
>> 2003.
>>
>> Regards, Dave S
>>
>> ----- Original Message ----- 
>> From: "John Grierson" <griersoft@xxxxxxxxxxxx>
>> To: <mso@xxxxxxxxxxxxx>
>> Sent: Thursday, December 27, 2007 9:48 PM
>> Subject: [mso] Macro sorting a list
>>
>>
>>>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
> *************************************************************
> 

*************************************************************
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: