Trying to have a specific date range show when the sort by date macro is run. Specifically the current pay period should be the first line showing, all dates before current pay period would be above that. I have a hidden sheet that I could put dates for each pay period but not sure if I have to do that. Below is what I have so far but obviously that sorts with January showing on the top line.
Any help would be much appreciated. Thank you.
VBA Code:
Sub SortbyDate()
'
' SortbyDate Macro
'
'
Rows("2:2").Select
Selection.AutoFilter
Range("B2").Select
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:=Range _
("B2"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Rows("2:2").Select
Selection.AutoFilter
Range("B263").Select
End Sub
Any help would be much appreciated. Thank you.