I need help with this VBA code, it's not sorting the sheet.
At first my Ranges were cell specific so I tried adjusting to get the LastRow info so that it would sort all the data instead of just the max row when I had recorded the macro, BUT it was at least sorting.
When I tired adding the Lastrow pieces, it doesn't sort at all now...
HELP thanks everybody!!
Dim Lastrow As Integer
Lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
ActiveWorkbook.Worksheets("Key Customer Detail").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Key Customer Detail").Sort.SortFields.Add Key:= _
Range("D2" & Lastrow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Key Customer Detail").Sort.SortFields.Add Key:= _
Range("E2" & Lastrow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
ActiveWorkbook.Worksheets("Key Customer Detail").Sort.SortFields.Add Key:= _
Range("C2" & Lastrow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Key Customer Detail").Sort
.SetRange Range("A1" & Lastrow)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Bookmarks