I have 2 sheets. One named LM and the other named D. I'm trying to filter the data in column B on sheet D for values that match the value in cell B3 on the LM sheet. The data in column B of the D sheet and the value in B3 of the LM sheet are m/d/yyyy values formatted as mmm-yy. When I run this code, the first filter line runs fine, but the second one filters all of the data out even though there are about 15 records that should be filtered to. It's probably something simple, but I haven't been able to find anything online that successfully explains how to achieve the goal.
VBA Code:
Sub CreateViews()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim m As Workbook
Dim mD As Worksheet, mLM As Worksheet
Dim rDate As Date
Dim mDLR As Long, mLMLR As Long
Set m = ThisWorkbook
Set mD = m.Sheets("D")
Set mLM = m.Sheets("LM")
mDLR = mD.Range("A" & Rows.Count).End(xlUp).Row
mLMLR = mLM.Range("A" & Rows.Count).End(xlUp).Row
'Removes filters from the working data if any exist.
If mD.AutoFilterMode Then mD.AutoFilterMode = False
'Unhides any columns and rows that may be hidden on the working data.
With mD.UsedRange
.Columns.EntireColumn.Hidden = False
.Rows.EntireRow.Hidden = False
End With
mD.Activate
With mD.Range("A1:X" & mDLR)
.Sort Key1:=.Columns("I"), Order1:=xlAscending, _
Key2:=.Columns("G"), Order1:=xlAscending, _
Key3:=.Columns("K"), Order1:=xlAscending, _
Orientation:=xlTopToBottom, Header:=xlYes
End With
rDate = mLM.Range("B3").Value
With mD.Range("A1:X" & mDLR)
.AutoFilter Field:=9, Criteria1:="LM", Operator:=xlFilterValues
.AutoFilter Field:=2, Criteria1:="=" & rDate, Operator:=xlFilterValues
End With