Sort1Col

Sorts a column in Excel, easily, with options

CodeFunctionName
What is this?

Public

Tested

Original Work
Sub Sort1Col(Optional ColName = "A", Optional Order_Asc1_Desc2 = 1, Optional SheetName = "This", Optional WBName = "This")
' Sort a single column, starting from row 2, assuming row 1 has column header
If SheetName = "This" then SheetName = Activesheet.name
If WBName = "This" Then WBName = ThisWorkbook.Name
OOrd = xlAscending
If Order_Asc1_Desc2 = 2 Then OOrd = xlDescending
Row1 = WorksheetFunction.CountA(Workbooks(WBName).Worksheets(SheetName).Range(ColName & 1).EntireColumn)
Workbooks(WBName).Worksheets(SheetName).Range(ColName & 2, ColName & Row1).Sort ShD.Range(ColName & 1), OOrd, , , , , , xlNo
End Sub

Optional ColName, Optional Order_Asc1_Desc2, Optional SheetName, Optional WBName

Views 3,135

Downloads 1,277

CodeID
DB ID