Solved

Why do my wildcards in VBA not work

Posted on 2014-02-14
8
247 Views
Last Modified: 2014-02-17
I have the below code , but it does not work.  As an example if AA2 has "501D" as the value and D2 has a value of JonesCo/////ty501D.00 no match is found even though the string in AA2 contains 501D ?  Any suggestions ?

IF .Range("AA" & intRow) Like "*" &  .Range("D" & intRow) & "*" THEN
msgBox "Partial Match Found"

ELSE

END IF
0
Comment
Question by:upobDaPlaya
8 Comments
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39860800
It works for me.

Kevin
0
 
LVL 81

Assisted Solution

by:zorvek (Kevin Jones)
zorvek (Kevin Jones) earned 150 total points
ID: 39860802
Set a breakpoint and inspect intRow. Make sure it's 2.

Kevin
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 350 total points
ID: 39860803
Looks like you're doing it in reverse.  If D2 has the full text and AA2 has "501D" then you should be using:
IF .Range("D" & intRow) Like "*" & .Range("AA" & intRow) & "*" THEN

Open in new window

Ron
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39860805
I had my test data backwards too!

That's it.

Kevin
0
 

Author Comment

by:upobDaPlaya
ID: 39860821
Aaaarhhhg.. I was banging my head on this one.  Thanks !
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 39863085
sorry...wrong area
0
 

Author Closing Comment

by:upobDaPlaya
ID: 39866361
Saved me a boatload of time...Thanks !
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 39866617
I appreciate the points but Ron nailed it and I missed it. If I were grading he would get all the points.

My idea of setting breakpoints and inspecting variables is sound advice and, if that's why you gave me points, I can accept that.

Kevin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question