Sort Worksheet Records By Column

K

Kenny

I need to write code to sort the records contained in a sheet named tracker
by column b (contains a formula that results in a numeric value) in
descending order. The row numbers change but will always start with row 3 and
end with how many ever rows have data. Also all columns will be included. I
want to prevent sorting so that blank rows are sorted to the top.
 
C

cush

Does this work for you?

Sub SortMyRng()
Dim Rng as range

'Note: you must not have anything in row 2 or any cell immediately around
your Rng
' If you have headers, you may need to adjust
Set Rng = Sheets("tracker").Range("A3").CurrentRegion
Rng.Sort Key1:=Range("B3"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top