Hi All,
I have a macro that will sort rows 8 to 57 by columns D, E, and F
However, what I want to do is change the fixed range to a dynamic range. This is so when I add rows after row 57 I don't have to go back in and re-edit this macro. Nothing above row 8 is to be included in the sort.
I'd like this macro to be used on the activesheet as opposed to a named sheet.
Open to all and any ideas and thanks.
I have a macro that will sort rows 8 to 57 by columns D, E, and F
Code:
Sub Sortcolums()
Dim rCount As Long
rCount = Evaluate("COUNT(" & ActiveSheet.Name & "!D8:D57)")
With ActiveSheet.Sort
With .SortFields
.Clear
.Add Key:=Range("D8").Resize(rCount), Sorton:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
.Add Key:=Range("E8").Resize(rCount), Sorton:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
.Add Key:=Range("F8").Resize(rCount), Sorton:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
End With
.SetRange Range("C7:AP7").Resize(rCount + 1)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
However, what I want to do is change the fixed range to a dynamic range. This is so when I add rows after row 57 I don't have to go back in and re-edit this macro. Nothing above row 8 is to be included in the sort.
I'd like this macro to be used on the activesheet as opposed to a named sheet.
Open to all and any ideas and thanks.