Hello All,
I'm new to the forum (and VBA), and am hoping for some help with an issue. I'm experimenting with creating a macro by recording, and I'm running into a hiccup with one of the filter steps.
The spreadsheet has 25 columns and I need to filter a handful of them. The last step is looking 61 days ahead, which I usually do by "Date Filters > Before..." and scrolling to the correct date on the calendar. This (as expected) has resulted in the VBA specifically filtering to the resulting date only (2/10/2020). I've tried a few things, none of which work and are probably wrong in a variety of ways haha. I'm not sure if I need to set use Dim sum or something? If so, I'm not really sure how to work that into full code, as most of what I'm finding online is a sub that is only for that single step.
It might also be worth mentioning that the dates are actually formulas (one of them a basic Cell+/-X and the other a WORKDAY formula). I've tried substituting "today()+61" instead of "2/10/2020" but that doesn't seem to work. Any help would be very appreciated! Thanks.
Here is the full VBA:
Sub SortCadenceA10()
'
' SortCadenceA10 Macro
' This Macro filters A-10 CDRLs for Cadence, by removing MRTS and any that have been delivered to the customer, and then sorting oldest to newest CDD 61 days out.
'
'
ActiveWindow.SmallScroll Down:=-39
ActiveSheet.Range("$A$2:$U$271").AutoFilter Field:=10, Criteria1:="="
ActiveWorkbook.Worksheets("CDRLs").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("CDRLs").AutoFilter.Sort.SortFields.Add Key:=Range( _
"I2:I271"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("CDRLs").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$2:$U$271").AutoFilter Field:=1, Criteria1:=Array( _
"A-10 TO-0004 IOS", "A-10 TO-0005 SECB", "A-10 TO-0006 Suite 10"), Operator:= _
xlFilterValues
ActiveSheet.Range("$A$2:$U$271").AutoFilter Field:=9, Criteria1:= _
"<2/10/2020", Operator:=xlAnd
ActiveWindow.SmallScroll Down:=-36
End Sub
Bookmarks