Hi
When I run the below I get an error, it only seems to happen when there is only one row to sort:
lr2 = Range("D" & Rows.Count).End(xlUp).Row
Range("D1:N" & lr2).Select
ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add2 Key:=Range("N1:N" & lr2), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Data").Sort
.SetRange Range("D1:N" & lr2)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Does it fall over because I only have one row to sort?
When I run the below I get an error, it only seems to happen when there is only one row to sort:
lr2 = Range("D" & Rows.Count).End(xlUp).Row
Range("D1:N" & lr2).Select
ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add2 Key:=Range("N1:N" & lr2), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Data").Sort
.SetRange Range("D1:N" & lr2)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Does it fall over because I only have one row to sort?