Fixed

Board Regular
Joined
Apr 28, 2017
Messages
95
Hello!

When I'm trying to find some text in another it can be found as a part of word.
For example:

Code:
HappyText = "The best [B]cat[/B]alogue."
HappyPhrase = "[B]cat[/B]"
If InStr(HappyText, HappyPhrase) > 0

or

Code:
HappyText = "[B]Log[/B]ging into the cata[B]log[/B]ue."
HappyPhrase = "[B]log[/B]"
If InStr(HappyText, HappyPhrase) > 0

I want to find the same text/word:

Code:
HappyText = "You have a [B]log[/B] of the catalogue."
HappyPhrase = "[B]log[/B]"
If InStr(HappyText, HappyPhrase) > 0

I thing I should use the RexExp to find characters and digits left and right of HappyPhrase:
Something like this:
Code:
[A-Za-z0-9] & HappyPhrase & [A-Za-z0-9]

Please help with this problem!
Thank you in advance!
 
@Rick Rothstein:

"...especially since I am about to go to sleep for the 'night'."

:eek: Yowza! I didn't notice how late it is there. Off to bed to watch the sunrise!

I'm still on graveyard shift (much to my chagrin), so you have my compassion/empathy. Have a good rest my friend.

Mark
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Thank you Rick, I will try this construction "If InStrExact(TextName, TypeNameO, False) > 0 Then".
I guess your UDF should be added as the separate Module?
It does not have to be in a separate module (it could be if you want to do it that way)... you can just put it in the same module your UDF is in, just put it underneath the last "End Sub" or "End Function" in that module.
 
Upvote 0
Thank you Rick, I will try this construction "If InStrExact(TextName, TypeNameO, False) > 0 Then".
I guess your UDF should be added as the separate Module?
"but your earlier examples seemed to indicate you wanted a case insensitive search to take place."
Yes.

I've tried it - it works perfectly, Rick, thanks a lot!
Good night!
 
Upvote 0
@Rick Rothstein:

"...especially since I am about to go to sleep for the 'night'."

:eek: Yowza! I didn't notice how late it is there. Off to bed to watch the sunrise!

I'm still on graveyard shift (much to my chagrin), so you have my compassion/empathy. Have a good rest my friend.
I usually go to sleep about 6am and get up at 10am (yep, I only sleep around 4 hours per night).
 
Upvote 0
It does not have to be in a separate module (it could be if you want to do it that way)... you can just put it in the same module your UDF is in, just put it underneath the last "End Sub" or "End Function" in that module.

It works for me, thank you Rick!
 
Upvote 0
How is it possible? When I sleep 4 hours per night during few days, I feel so bad.
When I was somewhere in my late 40s, I start sleeping less (around 5 to 6 hours per night back then) and as the years progressed, I slowly started sleeping less and less. Now, I sleep around 3.5 to 4 hours per night. I don't know why, but it seems to work for me.
 
Upvote 0

Forum statistics

Threads
1,221,446
Messages
6,159,917
Members
451,603
Latest member
SWahl

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