View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Autofilter - Contains

Hi

The variable txt should not be in double quotes. The wild card string *
should be in quotes as mentioned below. Also from your code we dont get which
range you have selected. Please try the below.

txt = InputBox("Enter text to find")
Range("C1").AutoFilter field:=3, Criteria1:="*" & txt & "*"

If this post helps click Yes
--------------
Jacob Skaria

"al" wrote:

I'm trying to use macro below to find text in a filtered column using
macro below - it's not working when i input an existing text in the
input box - can someone pls correct my macro - thxs

Sub Macro()
'
'
txt = InputBox("Enter text to find")
'
Selection.AutoFilter Field:=3, Criteria1:="=*txt*",
Operator:=xlAnd
End Sub