K
KT
The following macro doesn't return any records.
Sub filtering()
Dim StartDate As String
Dim cStartDate As String
Dim cEndDate As String
StartDate = ActiveSheet.Cells(1, 4).Value
cStartDate = ">=" & StartDate
cEndDate = "<=" & ActiveSheet.Cells(1, 4).Value + 6
ActiveSheet.Cells(5, 1).Select
Selection.AutoFilter Field:=8, Criteria1:=cStartDate, _
Operator:=xlAnd, Criteria2:=cEndDate
End Sub
However, when I go manually go to check the autofilter
(custom...) window and then click OK, I get the expected
result of the filter.
It seems the criteria for the filter aren't working very
well programatically. How can I overcome this?
TIA for assistance.
KT
Sub filtering()
Dim StartDate As String
Dim cStartDate As String
Dim cEndDate As String
StartDate = ActiveSheet.Cells(1, 4).Value
cStartDate = ">=" & StartDate
cEndDate = "<=" & ActiveSheet.Cells(1, 4).Value + 6
ActiveSheet.Cells(5, 1).Select
Selection.AutoFilter Field:=8, Criteria1:=cStartDate, _
Operator:=xlAnd, Criteria2:=cEndDate
End Sub
However, when I go manually go to check the autofilter
(custom...) window and then click OK, I get the expected
result of the filter.
It seems the criteria for the filter aren't working very
well programatically. How can I overcome this?
TIA for assistance.
KT