Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro / Sort error


Hi, in the past I used an earlier version of Excel and this macro worked
fine:

Sub alpha_sort()
'
' alpha_sort Macro
' Macro recorded 1/21/2005 by Admin
'
' Keyboard Shortcut: Ctrl+k
'
Range("D2:CI250").Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
End Sub

But now when I try and run it, it comes up with this error:

Run-Time Error: '1004':
Application-defined or object-defined error

Does anyone know what is going wrong here?

Thanks for any help,
~Oni.


--
OniLink
------------------------------------------------------------------------
OniLink's Profile: http://www.excelforum.com/member.php...o&userid=19935
View this thread: http://www.excelforum.com/showthread...hreadid=518560

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Macro / Sort error

Hi Oni,
I'm using XL 2000 and your macro resulted in that error.
I recorded a macro and noted the last argument
"DataOption1:=xlSortNormal" missing, so I removed this argument from
your code and the error no longer resulted. It seems like an
unnecessary argument so removing it probably has no effect on your
macro's result.
You can also try removing other arguments as well. The macro recorder
often results in a lot of unnecessary code.
Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Macro / Sort error

Hi

You don't say what version of Excel you are using, but for me, in XL2003
the following ran fine

Range("D2:CI250").Select
Selection.Sort Key1:=Range("D2"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

However, the last line I thought only came in with XL2002 onward, and
does cause problems in XL versions lower than that.
The macro will run under earlier versions and in XL2003 if you amend to

Range("D2:CI250").Select
Selection.Sort Key1:=Range("D2"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

--
Regards

Roger Govier


"OniLink" wrote
in message ...

Hi, in the past I used an earlier version of Excel and this macro
worked
fine:

Sub alpha_sort()
'
' alpha_sort Macro
' Macro recorded 1/21/2005 by Admin
'
' Keyboard Shortcut: Ctrl+k
'
Range("D2:CI250").Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
End Sub

But now when I try and run it, it comes up with this error:

Run-Time Error: '1004':
Application-defined or object-defined error

Does anyone know what is going wrong here?

Thanks for any help,
~Oni.


--
OniLink
------------------------------------------------------------------------
OniLink's Profile:
http://www.excelforum.com/member.php...o&userid=19935
View this thread:
http://www.excelforum.com/showthread...hreadid=518560



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro / Sort error


Hi,

Thanks for your assitance. I am currently using Excel 2000, but I
believe I originally used Excel 2002 to make this. I tried removing the
line you specified, but it still generates an error. it now outputs:

Run-time error '1004':

Sort method of Range class failed


--
OniLink
------------------------------------------------------------------------
OniLink's Profile: http://www.excelforum.com/member.php...o&userid=19935
View this thread: http://www.excelforum.com/showthread...hreadid=518560

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Macro / Sort error

Hi

Try copying the code exactly as posted and placing it between your Sub,
End Sub sections.
I have just tried it again and it works fine for me on both XL2000 and
XL2003.

--
Regards

Roger Govier


"OniLink" wrote
in message ...

Hi,

Thanks for your assitance. I am currently using Excel 2000, but I
believe I originally used Excel 2002 to make this. I tried removing
the
line you specified, but it still generates an error. it now outputs:

Run-time error '1004':

Sort method of Range class failed


--
OniLink
------------------------------------------------------------------------
OniLink's Profile:
http://www.excelforum.com/member.php...o&userid=19935
View this thread:
http://www.excelforum.com/showthread...hreadid=518560



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Sort error jpas1954 Excel Discussion (Misc queries) 1 January 24th 07 04:24 PM
Sort Error Sprinks Excel Programming 2 December 22nd 05 06:43 PM


All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"