one way:
If your data is contiguous (No completely empty rows or columns) you can
let XL figure it out:
Sub Makro1()
Range("A1").Sort _
Key1:=Range("A1"), _
Order1:=xlAscending, _
Key2:=Range("L2"), _
Order2:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub
Another way, if there is a value in column 1 for all filled rows:
Range("A1:Q" & Range("A" & Rows.Count).End(xlUp).Row).Sort _
Key1:=Range("A1"), _
Order1:=xlAscending, _
Key2:=Range("L2"), _
Order2:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
In article ,
Rune_Daub wrote:
If I record a macro using the macro recorder. Then I get this
recording.
Sub Makro1()
Range("A1").Select
Range("A1:Q965").Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range _
("L2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortTextAsNumbers, _
DataOption2:=xlSortNormal
End Sub
Since my datasheet continues to get larger, I need the
Range("A1:......) to get larger as well.. How do I set it up to check
for the entire datasheet, so that I make sure that the entire sheet is
sorted in the progress???
---
Message posted from http://www.ExcelForum.com/