Excel XP sorting issue

R

Richard Clarke

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?
The code works perfectly in NT4, Excel 97, so my first instinct is
protections have changed. Sheets("Input").Protection.AllowSorting is
always false, even if I unprotect the sheet on the line prior to the
sort call

Many thanks
 
R

Richard Clarke

Myrna Larson said:
Have you tried modifying the code to determine the pre-existing protection settings, unprotect
the sheet, sort, then put the protection back to where it was?

Myrna

Thanks for the quick response.

The protection setting at the line before our sort call is
Protection.AllowSorting returns false. If we unprotect the sheet, it
still returns false. Unprotecting the sheet makes no difference to the
success / failure of the call to .Sort

Any ideas?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top