simple code with "abc" & "*"

  • Thread starter Thread starter Jack Sons
  • Start date Start date
J

Jack Sons

Hi al,

I have this line of code:
If Range(Cells(commentrij, 43), Cells(commentrij, 43)).Text = "abc"
& "*" Then

The cell contains abc followed by some other characters (depending on the
row) but this line will not work.
If I use the complete text of the content of the cell, e.g. "abcdef", the
line of code works properly.
I guess "abc" & "*" is incorrect, but I don't know why.
What shoud it be?
Thanks in advance for your help.

Jack Sons
The Netherlands
 
Wildcards don't work with this simple comparison.

You could use like:
if range(...).text like "abc*" then

or you could check the first 3 characters:
if left(range(...).text, 3) = "abc" then

ps. You don't need that .range(...) stuff--it's a single cell:

if cells(commentrij,43).text like ....
 
Back
Top