Using characters in LIKE for string

daveMo

New Member
Joined
Apr 15, 2014
Messages
10
Hey guys,

i know that this works:

Code:
bool = "*abc*" like "xabcx" 'true

Code:
dim a as string, b as string
a =  "abc"
b =  xxxacbxxx"

if True = a like b then
    '...
end if

Is it possible to use characters like * ? # in the second code:

Code:
if True = *a* like b then 'I know, that does not work

I hope you get what I mean. Or are there even better functions to solve the problem?

Thanks in advance.
 
thanks, for the help! Works fine :)

Code:
Sub test1()
Dim a As String, b As String


a = "abc"
b = "xabcx"
      If b Like "*" & a & "*" = True Then
      MsgBox ("T")
      Else: MsgBox ("F")
End If


End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top