• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Why do my wildcards in VBA not work

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
upobDaPlaya
Asked:
upobDaPlaya
2 Solutions
 
zorvek (Kevin Jones)ConsultantCommented:
It works for me.

Kevin
0
 
zorvek (Kevin Jones)ConsultantCommented:
Set a breakpoint and inspect intRow. Make sure it's 2.

Kevin
0
 
IrogSintaCommented:
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.

 
zorvek (Kevin Jones)ConsultantCommented:
I had my test data backwards too!

That's it.

Kevin
0
 
upobDaPlayaAuthor Commented:
Aaaarhhhg.. I was banging my head on this one.  Thanks !
0
 
rspahitzCommented:
sorry...wrong area
0
 
upobDaPlayaAuthor Commented:
Saved me a boatload of time...Thanks !
0
 
zorvek (Kevin Jones)ConsultantCommented:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now