Hi All
I would like to sort all rows with highlight to the bottom and I have used the macro recorder to create the macro below. However I would like to make this macro generic with unknown number of rows. Please could anyone help?
I would like to sort all rows with highlight to the bottom and I have used the macro recorder to create the macro below. However I would like to make this macro generic with unknown number of rows. Please could anyone help?
VBA Code:
Private Sub Highlight()
Columns("A:G").Select
ActiveWorkbook.Worksheets("Change Log").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Change Log").Sort.SortFields.Add2 Key:=Range( _
"C2:C36"), SortOn:=xlSortOnCellColor, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Change Log").Sort.SortFields.Add2 Key:=Range( _
"D2:D36"), SortOn:=xlSortOnCellColor, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Change Log").Sort.SortFields.Add2 Key:=Range( _
"G2:G36"), SortOn:=xlSortOnCellColor, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Change Log").Sort
.SetRange Range("A1:G36")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Last edited by a moderator: