Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Help with Sort

I want to sort a section of a spreadsheet -
I make a selection (say range("A22:D27")
I then want to sort that selection on column c then column d

when I recorded the macro this is what I got:
Range("A22:D27").Select
Selection.Sort Key1:=Range("C22"), Order1:=xlAscending,
Key2:=Range("D22" _
), Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False _
, Orientation:=xlTopToBottom
The problem is that the range is hard coded with "C22" - I want a variable
so I can select a range and then sort by column c then column d
How can I capture the top row number of the range so I can have this as a
dynamic macro?

Glen


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
Updating workbook with an alpha sort sheet and a numeric sort shee cjlatta Excel Discussion (Misc queries) 2 January 28th 09 12:00 AM
Sort by color: Is there an easy way to sort columns or rows in EX MGP Excel Worksheet Functions 5 August 16th 08 11:28 AM
sort function for dates does not sort properly in Office 2007 Exc. Rosalie Excel Worksheet Functions 1 November 22nd 07 10:25 PM
Excel sort by Fill Color by custom list sort Dash4Cash Excel Discussion (Misc queries) 2 July 29th 05 10:45 PM
Excel Sort function should not sort the cell formatting! Lisa D.N.1 Excel Worksheet Functions 1 December 28th 04 08:37 PM


All times are GMT +1. The time now is 07:43 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"