Solved

Why do my wildcards in VBA not work

Posted on 2014-02-14
8
242 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
 
LVL 81

Expert Comment

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

That's it.

Kevin
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

895 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now