Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macro works in XP but not 2000

Status
Not open for further replies.

Joylaw20

Instructor
Nov 2, 2000
19
0
0
CA
I am getting 2 errors on a macro I wrote in Excel 2002 when it is used with Excel 2000. Works fine with 2002.

1.
Run-Time Error:
Application-defined or object-defined error

The code is:
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

2.
Compile Error:
Named Argument not found:

Range("A1:D2000").Sort Key1:=Range("B2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Can anyone give me any direction as to what I'm missing?

Thanks,
Joyce
 
1st guess is to get rid of the "dataoption1" argument - don't think it's there in 97 so may not be there in 2000

Rgds, Geoff
Si hoc legere scis, nimis eruditionis habes
Want the best answers to your questions ? - then read me baby one more time - faq222-2244
 
Thanks xlbo;

I think that's the answer. The only way around it that I can think of is to open the text file and copy it over to the file where the macro is to be run. Any other workarounds that you know of?

Thanks,
Joyce
 
Well, the DataOption1 argument is optional so you don't need to have it there for the sort to work. I suggest you just leave it out and test to see if it still works ok. If it does, then continue without it and it should then work on both platforms

Rgds, Geoff
Si hoc legere scis, nimis eruditionis habes
Want the best answers to your questions ? - then read me baby one more time - faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top