Code:
Sub DateSort()
With Sheets("Bedstat")
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
End With
ActiveSheet.Unprotect Password:="grange"
Rows("6:6").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Bedstat").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Bedstat").Sort.SortFields.Add Key:=Range("E6:E" & LastRow), Sorton:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Bedstat").Sort
.SetRange Range("A6:A" & LastRow)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("F6").Select
End Sub
I get the error "Sort reference is not valid".
It should select data from rows 6 to the end row, and then sort based on column E
What am I doing wrong, its driving me mad!!
TIA