johnfbkennedyy
New Member
- Joined
- Sep 22, 2020
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hi all! I'm new to VBA and I am trying to create a text filter sub based on a changing cell. Basically it serves its function: when I update the search in the cell which is named "search_string" is automatically updates all of column D values that contain that text. The only problem is that when I delete the search, it only shows cells in column D that have contents. So for example if one row in column D has no text, it will not filter it in when the cell of search_string is empty. I have tried to change the text but I don't know how to change the criteria to make it filter the search_string text content including when its blank.
This is the code I have up until now:
Thanks in advance!
This is the code I have up until now:
VBA Code:
Private Sub Macro2(ByVal Target As Range)
Columns("D:D").Select
Selection.AutoFilter
Range("search_string").Select
Selection.Copy
ActiveSheet.Range("$D$2:$D$152184").AutoFilter Field:=1, Criteria1:= _
"=*" & Range("search_string").Value & "*", Operator:=xlAnd
End Sub
Thanks in advance!