I have a macro that sorts my data based on dates in Column B. As you can see, after the sort completes the cursor parks itself at Cell A1. What I'd like is for it to auto-scroll down to the current date (or closest date) in Column B. Here's my current code:
I suspect the
...needs some sort of =TODAY() code. Am I close?
Any suggestions would be appreciated.
Code:
Sub SortByDate()
Application.ScreenUpdating = False
ActiveWindow.SmallScroll Down:=-189
Rows("5:2000").Select
ActiveWindow.ScrollRow = 1426
ActiveWindow.ScrollRow = 4
ActiveWorkbook.Worksheets("Calendar").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Calendar").Sort.SortFields.Add Key:=Range( _
"B5:B2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Calendar").Sort.SortFields.Add Key:=Range( _
"D5:D2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Calendar").Sort.SortFields.Add Key:=Range( _
"C5:C2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Calendar").Sort
.SetRange Range("A5:BQ2000")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
Application.ScreenUpdating = True
End Sub
I suspect the
Code:
Range("A1").Select
...needs some sort of =TODAY() code. Am I close?
Any suggestions would be appreciated.
Last edited: