Why do my wildcards in VBA not work

Posted on 2014-02-14
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"


Question by:upobDaPlaya
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 81

Expert Comment

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

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.

LVL 29

Accepted Solution

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

LVL 81

Expert Comment

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

That's it.


Author Comment

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

Expert Comment

ID: 39863085
sorry...wrong area

Author Closing Comment

ID: 39866361
Saved me a boatload of time...Thanks !
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.


Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

728 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