VBA change filter match from INCLUDE to EXACT,

S

Snoopy

Hey guys
I expect my macro to set a filter by exact match based on a value in
range G2.
The (part of) macro goes like this:

Sub Search ()
Sheets("list").Select
On Error Resume Next
On Error GoTo 0
UserVal1 = Range("G2").Value
If UserVal1 = False Then
Exit Sub
Else
Selection.AutoFilter Field:=1, Criteria1:="*" & UserVal1 & "*",
Operator:=xlOr
End If
End Sub

However this macro dont find EXACT match - but INCLUDED match

Question 1: What correction do I have to make to instruct the macro to
find EXACT match to range G2?
Question 2: What correction do I have to make to instruct the macro to
find EXACT match to values in range G2, G3 or G4 (expression incudes
at least one of the 3 different words)?

Most gratefull to any advise that will make this work
Best regards Snoopy
 
D

Don Guillett

If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.
 
S

Snoopy

Try changing

Criteria1:="*" & UserVal1 & "*",

to

Criteria1:=UserVal1,

--
HTH,
Bernie
MS Excel MVP










– Vis sitert tekst –

Thanks guys
I will try this out :)
Best regards snoopy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top