A1: ID B1: Name C1: Department A2: 1 B2: Aamir C2: Admin A3: 2 B3: Priya C3: HR A4: 3 B4: John C4: IT Sub SearchFilter() Dim ws As Worksheet Dim searchValue As String Set ws = ThisWorkbook.Sheets("Sheet1") ' Change sheet name if needed searchValue = ws.Range("E3").Value ' Clear any previous filter On Error Resume Next ws.Range("A1").AutoFilter Field:=1 ws.Range("A1").AutoFilter Field:=2 ws.Range("A1").AutoFilter Field:=3 On Error GoTo 0 ' Apply filter if searchValue is not blank If searchValue <> "" Then ws.Range("A1:C100").AutoFilter Field:=2, Criteria1:="*" & searchValue & "*" Else ws.Range("A1:C100").AutoFilter End If End Sub In Excel, press Alt + F11 to open the VBA Editor. If the Project Explorer is not visible, press Ctrl + R Find your sheet name (e.g., "DataSheet"), you might see Sheet1 (DataSheet) Paste the below code Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Me.Range("E3")) Is Nothing Then Application.EnableEvents = False Call SearchFilter Application.EnableEvents = True End If End Sub
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter