Solved

Why do my wildcards in VBA not work

Posted on 2014-02-14
8
254 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
[X]
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
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
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.

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

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