Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default sort method frustration

David,

I can't think of much else that might be causing the problem. Is
worksheet containing sRange active when you execute the sort?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"David Wenahm" wrote in message
...
Chip,

Thanks for your Help!

Yes I have checked the srange address, I am sorting 6 six
columns of data and intsortcolumn2 = 6 prior and during
the statement. There is header data which is what the key
is pointing to.

Range address is $A$1:$F$154

srange is also set prior to the sort.

further suggestions?

David

-----Original Message-----
David,

Does the srange range contain the key cell?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"David Wenham" wrote in message
...
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?



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need really fast method to sort data for my part numbering spread Chris Dundorf Excel Discussion (Misc queries) 7 March 24th 10 06:05 PM
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM
Please post this thread a complete correct method, method about te Nast Runsome New Users to Excel 0 February 23rd 08 09:42 PM
VBA Sort method w/more than 3 Keys KenRoy Excel Discussion (Misc queries) 1 August 26th 05 10:48 PM
Sort method of range Richard Clarke Excel Programming 7 July 25th 03 04:42 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"