View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
David Wenham David Wenham is offline
external usenet poster
 
Posts: 1
Default sort method frustration

The is method the first sort works fine.

srange.Sort _
Key1:=Cells(1, intSortColumn), Order1:=xlAscending,
Header:=xlYes

When I want to sort directly after by second column.

I receive runtime error "1004"

srange.Sort _
Key1:=Cells(1, intSortColumn2), Order1:=xlAscending,
Header:=xlYes

intsortcolumn2 does hold a value
srange is a valid object.
row 1 is the header.

Ideally I would like sort by both keys at the same time.

I used the macro record

Selection.Sort Key1:=Range(Cells(1, intSortColumn),
Cells(1, intSortColumn)), Order1:=xlAscending, _
Key2:=Range(Cells(1, intSortColumn2), Cells(1,
intSortColumn2)) _
, Order2:=xlAscending, Header:=xlYes,
OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal

Same error results.
Why is sort such a pain in the you know where?

Any ideas?