Home » excel » excel – VBA Macro To Search AutoFilter

excel – VBA Macro To Search AutoFilter

Posted by: admin May 14, 2020 Leave a comment

Questions:

I currently have a code which searches an AutoFilter, but searches it for exactly what I put within the quotations.

ActiveSheet.Range(Selection, Selection.End(xlUp)).AutoFilter Field:=5, Criteria1:="CLO "

What I need is a code which will search the filter for the word say “CLO ” within each line. So say there’s a line which says “CLO has been booked…” I want that to come up in the search. Currently, my search is returning no results since it is searching specifically for “CLO “.

How to&Answers:

Update your code with the following

ActiveSheet.Range(Selection, Selection.End(xlUp)).AutoFilter _
    Field:=5, Criteria1:="CLO *"

* indicates that as long as the text begins “CLO “, the row will be returned, regardless of text follows it.