macro sort

A

atv

HI there
Can anybody help me with a simple Macro to sort the sheet according to 3rd
column and the number of rows is not known. Please explain about the
important part of Macro too.
Thanks
 
G

Gary''s Student

Sub Macro1()
n = Cells(Rows.Count, 3).End(xlUp).Row
Range("A1:C" & n).Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

This just does the first three columns. The first line figures how far down
to go. The next lines selects the block to be sorted. The last actually
performs the sort.
 

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