Hi,
How could I change the following code to filter the sheet by cell value instead of text box values?
Any help on this would be kindly appreciated.
How could I change the following code to filter the sheet by cell value instead of text box values?
Code:
Private Sub Change()
Dim FilterDate1 As Date
Dim FilterDate2 As Date
FilterDate1 = CDate(txtFrom.Value)
FilterDate2 = CDate(txtTo.Value)
With Worksheets("My")
.Rows("16:16").AutoFilter
With .Range("$C$16")
.AutoFilter Field:=5, Criteria1:=">=" & Format(FilterDate1, .Range("$H$17").NumberFormat), _
Operator:=xlAnd, Criteria2:="<=" & Format(FilterDate2, .Range("$H$17").NumberFormat)
End With
End With
End Sub
Any help on this would be kindly appreciated.