LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Autofilter - Contains

A more generic way of doing this is to simply use AutoFilter.Range

Dim txt As String

txt = InputBox("Enter text to find")

txt = "*" & txt & "*"

With ActiveSheet
.AutoFilter.Range.AutoFilter Field:=3, Criteria1:=txt
End With

or you can do it the following way. The advantage of this way is that the
worksheet with the AutoFilter does not have to be the ActiveSheet.

With Sheets("Sheet1")
.AutoFilter.Range.AutoFilter Field:=3, Criteria1:=txt
End With

It does not matter whether you concatenate the asterisks before the
AutoFilter code as I have done or as Jacob did it in his example. I just did
it that way to demonstrate an alternative.

Regards,

OssieMac



"Jacob Skaria" wrote in message
...
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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
How to Sort within AutoFilter with Protection on (and AutoFilter . giblon Excel Discussion (Misc queries) 1 February 16th 06 12:23 PM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"