View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
andres a andres a is offline
external usenet poster
 
Posts: 6
Default Sort method of range

Rich
it looks to me that you are missing something on the first
line of your code.

Range(cells(15,1), Cells(endrow,???????
where is the end of the cells
if it is the next line you are missing the space and the
udnerscore.

Check the protection.
I do not belive you can do sorts when cell are protected.

Andres

-----Original Message-----
Hi

I am performing a sort programatically in Excel 2002 on

Windows XP

The line of code to sort is as follows:

Range(Cells(15, 1), Cells(endrow,
Range("iNonQualStatus").Column)).Sort Key1:=Range

("iItemType"),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=ordercustomnumber,

MatchCase:=False,
Orientation:=xlTopToBottom

This throws the following error:

Sort Method of Range class failed

The sheet is protected both programatically and using

Excel's protect
option from the menus.

No matter what I try regarding setting different

protections at
run-time or saving the sheet with different protections,

whenever I
hit the line of code above, the allowsorting propery is

false.

In order to test sorting I created a new workbook and

sheet to test
the sorting functionality and even this fails - with no

protections,
and allowsorting reporting true when interrogated at

runtime (although
this time the error is 1004 Application-defined or object-

defined
error).

Can anyone suggest why this doesn't work in either

scenario?

Many thanks

--

Rich (change nospam to mlu035 to reply direct)
.