I am trying to adapt this code to sort worksheet "DriverDetails" by column A after an addition of information. The sub SortDetails() is called by the update macro.
It is not sorting and I cant see why. Code should take account of any number of rows and any number of columns. Data has a header row.
Function LastRow()
Dim rowfind As Long
rowfind = WorksheetFunction.CountA(Range("A:A"))
LastRow = rowfind
End Function
Function LastColumn()
Dim columnfind As Long
columnfind = WorksheetFunction.CountA(Range("1:1"))
LastColumn = columnfind
End Function
Sub sortdetails()
Dim sortdata
sortdata = "A1:" & Cells(LastRow, LastColumn).Address(0, 0)
With ActiveWorkbook.Worksheets("DriverDetails").Sort
.SetRange Range(sortdata)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Any pointers appreciated....
Bookmarks