The following code sorts data rows in ascending manner by the date in column A. How could I make the code to sort data rows by column value in B instead of column A. Meaning I have serial numbers in the custom format 0001 and so on.
Code: Select all
Sub SortSerial()
Dim c As Integer
With Sheets("OrderData").Range("A1").CurrentRegion
c = .Find(What:="Date", After:=.Cells(1, 1), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Column
.Sort Key1:=.Cells(1, c), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub
Any help on this would be kindly appreciated.
Thanks in advance.