vba string function?

vbaNewby

Board Regular
Joined
Jan 26, 2011
Messages
138
Hello guru's,

I want to know if there is some type of string function that satisfies this example:

myString = "hel"

Cell1: "helloworld"
Cell2: "hel loworld"
Cell3: "hel lo world"

I want to return false for cell 1 but true for cell 2 and 3. Instr function (xlpart param???) will return true for all three. I basically want to return true if "hel" is a substring but its own word within a string.

I hope there is sometype of way to do this without having to write my own function!

Thanks in advance.
 
Consistent with your original post, it shouldn't have either.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
How about any trailing/leading non-printing character?

eg CHAR(10)
 
Upvote 0
How about any trailing/leading non-printing character?

eg CHAR(10)

No, I simply opened up a new workbook plugged in the strings in cell A1 and B1 and plugged in the formula. No hidden, non printable characters.

Besides if you need a trailing space in A1 then this function isn't going to work for me!

My search string will be "hel" not "hel "

If I can get this to work however, I can manipulate the string in VBA to put in that extra space but I can't get it to work!
 
Upvote 0
A1 should contain the three characters hel and nothing else.
 
Upvote 0
shg or norey or anyone!

Is this the same as using an excel function? Will this satisfy my 3 conditions:

Code:
InStr(1, " " & ActiveCell.Value & " ", " depreciation ", vbTextCompare) > 0</pre>

THANK YOU! As always :)
 
Upvote 0
If you mean is InStr like SEARCH then yes.

As for the 3 conditions, what 3 conditions?

There's only one in that code.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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