ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting problem (https://www.excelbanter.com/excel-programming/398788-sorting-problem.html)

Francis Hookham

Sorting problem
 
Any idea why the following runs on laptop with XL 2002 but not on desktop
with XL 2000.

It is in a subroutine called by another. The sub does not start but throws
up the comment 'Named argument cannot be found' and 'DataOption1' is
highlighted?



Range("A1:D" & iCount).Sort Key1:=Range("C1"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal



Francis Hookham



Dave Peterson

Sorting problem
 
Remove this portion: ", DataOption1:=xlSortNormal"

This option was added in xl2002.

Francis Hookham wrote:

Any idea why the following runs on laptop with XL 2002 but not on desktop
with XL 2000.

It is in a subroutine called by another. The sub does not start but throws
up the comment 'Named argument cannot be found' and 'DataOption1' is
highlighted?

Range("A1:D" & iCount).Sort Key1:=Range("C1"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

Francis Hookham


--

Dave Peterson

Chip Pearson

Sorting problem
 
Francis,

The 'DataOption1' sort option was added with Excel 2002. It is not
recognized by earlier versions. When you are working with multiple versions
of Excel, you must be sure you code for the earliest version. Otherwise, as
you have seen, the code may not work.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Francis Hookham" wrote in message
...
Any idea why the following runs on laptop with XL 2002 but not on desktop
with XL 2000.

It is in a subroutine called by another. The sub does not start but throws
up the comment 'Named argument cannot be found' and 'DataOption1' is
highlighted?



Range("A1:D" & iCount).Sort Key1:=Range("C1"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal



Francis Hookham




Francis Hookham

Sorting problem
 
Many thanks Chip and Dave

I do most of the programming in 2002 on the Laptop (it is newer and much
faster!) but, now I understand the problem I'll remove similar offending
code if it occurs and chack the macro still runs correctly.

Francis


"Chip Pearson" wrote in message
...
Francis,

The 'DataOption1' sort option was added with Excel 2002. It is not
recognized by earlier versions. When you are working with multiple
versions of Excel, you must be sure you code for the earliest version.
Otherwise, as you have seen, the code may not work.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Francis Hookham" wrote in message
...
Any idea why the following runs on laptop with XL 2002 but not on desktop
with XL 2000.

It is in a subroutine called by another. The sub does not start but
throws up the comment 'Named argument cannot be found' and 'DataOption1'
is highlighted?



Range("A1:D" & iCount).Sort Key1:=Range("C1"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal



Francis Hookham







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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com