excel vba sort table multiple columns code example
Example: vba sort multiple columns
' Sorts a range with multiple criterias
Sub MultipleColumnsSort()
With ActiveSheet.Sort
.SetRange Range("A1:D10")
.SortFields.Add Key:=Range("A1"), Order:=xlAscending
.SortFields.Add Key:=Range("B1"), Order:=xlDescending
' If range includes headers
.Header = xlYes
.Apply
End With
End Sub