Sort data from smallest to largest

M

Mary Pencey

I need to sort data in Column A in numerical order from smallest to
largest, and that is correct for any number of rows. So this macro
could be run on a column that has data on rows 3-200, or on rows
3-500.

Does anyone know how to write code in VBA for this in excel 2007?
 
O

Otto Moehrbach

Mary
This little macro will sort column A from A2 down to the last entry in
that column. I assumed you have headers in row 1. HTH Otto
Sub SortColA()
Dim rColA As Range
Set rColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
rColA.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
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

Similar Threads


Top