Solved

Why do my wildcards in VBA not work

Posted on 2014-02-14
8
241 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

757 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