Find separeted words in string

peter_sjogarde

Board Regular
Joined
Feb 13, 2012
Messages
56
I have a VBA macro that looks for words that occur in strings. I do not want to match words that occur as part of other words, e.g. “bar” in barrier. I would like to match “ bar “ or “.Bar “ or “bar-“ “-bar”, i.e the word “bar”. Is there a function or application to do this?

Piece of code:
Code:
    For j = 2 To 16307
        title = LCase(wosData(j, 2))
        description = LCase(wosData(j, 3))
        abstract = LCase(wosData(j, 4))
        If InStr(1, title, keywords(i, 2), vbTextCompare) > 0 Or _
            InStr(1, description, keywords(i, 2), vbTextCompare) > 0 Or _
            InStr(1, abstract, keywords(i, 2), vbTextCompare) > 0 Then
            '''do something'''
        End If
    Next j
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Watch MrExcel Video

Forum statistics

Threads
1,123,295
Messages
5,600,780
Members
414,405
Latest member
Zaurb

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
Top