holograful
New member
- Joined
- Feb 6, 2020
- Messages
- 1
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- Excel 2016
Hi,
I need to filter a Date column using VBA code and a text box.
The user will type in the text box and the data will filter.
Below is the code I am using to filter columns that contain text data, and it works as intended:
I need to filter a Date column using VBA code and a text box.
The user will type in the text box and the data will filter.
Below is the code I am using to filter columns that contain text data, and it works as intended:
Code:
Private Sub textbox_PanelDate_Change()
Dim S As String
S = textbox_PanelDate
If Len(S) > 0 Then
Range("B6").AutoFilter Field:=18, Criteria1:="*" & S & "*"
Else
Range("B6").AutoFilter Field:=18
End If
End Sub
What is the code to use to filter a column that contain date data?
The column is formatted as short-date. See the uploaded images for reference.
When I type in the Panel text box the spreadsheet is filtering (Panel filter.jpg).
I expect the same result when I type in the Panel Date text box - but the result is blank cells only (Panel Date No filter.jpg).
I use the above code for both text boxes.
Let me know if you need more info.
Thank you.When I type in the Panel text box the spreadsheet is filtering (Panel filter.jpg).
I expect the same result when I type in the Panel Date text box - but the result is blank cells only (Panel Date No filter.jpg).
I use the above code for both text boxes.
Let me know if you need more info.
Cross-posted
Filter a Date column using VBA - OzGrid Free Excel/VBA Help Forum
Filter a Date column using VBA
Filter a Date column using VBAFilter a Date column using VBA - OzGrid Free Excel/VBA Help Forum
Filter a Date column using VBA