Sort field is empty, this is your problem. I have never used a Sort object like yours, but I see that you have not defined a key or range for sorting, but only a range that needs to be sorted. A key must be defined, for example Range ("A4") or something else. I looked at it, it should have .sortfields.add (range), for example:
'Sort the active rows With ActiveWorkbook.Worksheets("Product Backlog").Sort .SetRange Range("A4:F51") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .SortFields.Add Key:=Range("A4:F51").Columns(1), SortOn:=xlSortOnValues, _ Order:=xlDescending, DataOption:=xlSortNormal .Apply End With
I use the sort function as follows:
ActiveWorkbook.Worksheets("Product Backlog").Range("A4:F51").Sort _ Key1:= ActiveWorkbook.Worksheets("Product Backlog").Range("A4:F51").Columns(1), _ Header:= xlYes, _ Orientation:=xlSortColumns, _ MatchCase:=False, _ SortMethod:=xlPinYin
Motes source share