ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with using the "Like"-Operator. (https://www.excelbanter.com/excel-programming/305385-problem-using-like-operator.html)

Joepy

Problem with using the "Like"-Operator.
 
Hi, I have just encountered a very strange problem when comparing
strings:

Here is an example:

If "10" Like "[7,8,9,10,11]" Then
MsgBox "Found!"
Else
MsgBox "Not found!"
End If

The result is "Not found", although it should find the 10 inside the
other string. The strange thing is it finds 7,8 and 9, but not the
two-digit numbers.

How can I get this to work?
Any help is appreciated.
Regards,
Markus

Kostis Vezerides

Problem with using the "Like"-Operator.
 
Markus,
the order of the operands is important. Also you need the
wildcards:

If "[7,8,9,10,11]" Like "*10*" Then
MsgBox "Found!"
Else
MsgBox "Not found!"
End If

HTH
Kostis

-----Original Message-----
Hi, I have just encountered a very strange problem when

comparing
strings:

Here is an example:

If "10" Like "[7,8,9,10,11]" Then
MsgBox "Found!"
Else
MsgBox "Not found!"
End If

The result is "Not found", although it should find the 10

inside the
other string. The strange thing is it finds 7,8 and 9,

but not the
two-digit numbers.

How can I get this to work?
Any help is appreciated.
Regards,
Markus
.



All times are GMT +1. The time now is 12:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com