Find part of a word in Advanced Filter Code
Use this, and type your desired words into either A2 or B2. This assumes that your criteria are
entered into A1:B2 - headers in A1 and B1, and values in A2 and B2.
HTH,
Bernie
MS Excel MVP
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$A$2" Or _
Target.Address = "$B$2" Then
Application.EnableEvents = False
Target.Value = "*" & Target.Value & "*"
Range("Database").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Range("A1:B2"), _
Unique:=False
Application.EnableEvents = True
End If
End Sub
"Sierras" wrote in message
...
On Fri, 10 Mar 2006 12:44:37 -0500, Bernie Deitrick <deitbe consumer dot org wrote:
Range("E4").Value = "*" & InputBox("Word to look for") & "*"
Seems to work the same with or without the criteria range. Now I have this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$A$2" Or _
Target.Address = "$B$2" Then
Range("Database").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Range("B1:B2"), _
Unique:=False
End If
End Sub
The line suggested Range("E2").Value = "*" & InputBox("Word to look for") & "*"
creates a circular that I have to hit Ctrl - Break to get out of. I don't know where to put this
line in order to make it work. In any case, it would be nicer to be able to just put the word
that I'd like to search for in B2 and have the code put in the *'s before and after without a
command box.
|