hi all, i have been trying to write code to sort data in column D in a sheet. I need to only sort the data from row 2 to the last used row in D. i am receiving a run-time error 438 and cannot figure out why. thankful for any help!
Sub Macro5()
Dim LR As Long
With Sheets("Sheet1")
LR = .Range("D" & Rows.Count).End(xlUp).Row
.Sort.SortFields.Add Key:=.Range("D2:D" & LR), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With .Sort
.SetRange .Range("D2:D" & LR) <<<<<<ERRORS HERE
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
End Sub
Bookmarks