Change range from cells to sheet?

J

JBW

Can I change the range from cells to sheet in following. I have problem when
data is bigger than range that macro currently selects, only sorts to 159th
line. ?

Range("A1:J159").Sort Key1:=Range("B3"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
 
G

Gary''s Student

n = Cells(Rows.Count, "J").End(xlUp).Row
s = "A1:J" & n
Range(s).Sort.........

Just replace the address in the Range with the string
 
Top