ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro sort (https://www.excelbanter.com/excel-programming/408499-macro-sort.html)

atv

macro sort
 
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

Gary''s Student

macro sort
 
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.
--
Gary''s Student - gsnu200776


"atv" wrote:

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



All times are GMT +1. The time now is 01:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com