I am still learning Excel VBA and would appreciate it if anyone can help me get this right. I want to filter a date column based on a startDate and endDate I specified in a sheet called DateMaster. When I run the macro, it gives me Run Time Error 13, Start Date = 0. Below is my code.
Sub FIlterCopy()
Dim StartDate As Long
Dim EndDate As Long
StartDate = ThisWorkbook.Worksheets("DateMaster").Range("C2").Value
EndDate = ThisWorkbook.Worksheets("DateMaster").Range("D2").Value
Application.ScreenUpdating = False
ThisWorkbook.Worksheets("FilterMaster").Activate
Range("A:BA").Select
Selection.ClearContents
Application.Workbooks.Open ("C:\WRI\Data\Revenue Update.xls")
Windows("Revenue Update.xls").Activate
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:= _
"=Backlog", Operator:=xlOr, Criteria2:="=RMA"
Selection.AutoFilter Field:=29, Criteria1:= _
"=Direct"
Selection.AutoFilter Field:=20, Criteria1:=">=" & StartDate, Operator:=xlAnd, Criteria2:="<=" & EndDate
Application.ScreenUpdating = True
End Sub