Find Last Row To Sort On


Posted by Joseph on January 10, 2002 3:03 PM

I have a Monthly sheet which can have various amounts of rows. Always same columns. A - G.

I manually select the cells each month from A5 to last cell and then select Data sort and sort on G then F then D.

Could someone help me with a macro for this.
I have read here how to find the last row, but not sure how to put this into the range A5:G??.

Thanks
Joe.


Posted by Tom Dickinson on January 10, 2002 4:05 PM

Try this:
Sub ShortSort()
Range("A5", Range("G5").End(xlDown).AddressLocal).Sort Key1:=Range("G1"), Order1:=xlAscending, Key2:=Range("F1") _
, Order2:=xlAscending, Key3:=Range("D1"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


You may want to record a macro of the sort process as the criteria in mine may not be the same as yours. Just replace "Selection" in your macro with the verbage before the word ".sort" in my macro.




Posted by Joseph on January 15, 2002 12:29 AM

Tom,
This seems to work fine.
Thank you very much.

Joe.