Hi,
I am trying to sort the populated data in a worksheet. Column A has a few records with the cell blank and I want these at the bottom. I have the code below. It runs with no errors but doesn't seem to be sorting correctly.
Sub Sort()
Sheets("XXXX").Activate
ActiveSheet.UsedRange.Select
With ActiveSheet.Sort
.SortFields.Add Key:=Range("A1"), Order:=xlDescending
.SortFields.Add Key:=Range("C1"), Order:=xlAscending
.SortFields.Add Key:=Range("D1"), Order:=xlAscending
.SortFields.Add Key:=Range("E1"), Order:=xlAscending
.SortFields.Add Key:=Range("F1"), Order:=xlAscending
.SetRange Selection
.Header = xlYes
.Apply
End With
End Sub
I am trying to sort the populated data in a worksheet. Column A has a few records with the cell blank and I want these at the bottom. I have the code below. It runs with no errors but doesn't seem to be sorting correctly.
Sub Sort()
Sheets("XXXX").Activate
ActiveSheet.UsedRange.Select
With ActiveSheet.Sort
.SortFields.Add Key:=Range("A1"), Order:=xlDescending
.SortFields.Add Key:=Range("C1"), Order:=xlAscending
.SortFields.Add Key:=Range("D1"), Order:=xlAscending
.SortFields.Add Key:=Range("E1"), Order:=xlAscending
.SortFields.Add Key:=Range("F1"), Order:=xlAscending
.SetRange Selection
.Header = xlYes
.Apply
End With
End Sub