ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Determine if 2 cells share a common word (https://www.excelbanter.com/excel-worksheet-functions/253312-determine-if-2-cells-share-common-word.html)

Paul C

Determine if 2 cells share a common word
 
I have a list with two text columns. I want to identify the rows where the
cells share a common word. For example,
Fujitsu Consulting in col A and Software Engineer in col B would not share a
common word but
Starbucks in col A and Starbucks Barista in col B would share a common word.



ryguy7272

Determine if 2 cells share a common word
 

Sub Highlight_Word()
Dim rng As Range
Dim Cell As Range
Dim start_str As Integer


myword = InputBox("Enter the search string ")

Mylen = Len(myword)
Set rng = Selection
For Each Cell In rng
' start_str = InStr(cell.Value, myword) '(case sensitive)
start_str = InStr(1, Cell.Value, myword, vbTextCompare) '(non case
sensivive)

If start_str Then
Cell.Characters(start_str, Mylen).Font.ColorIndex = 3
End If
Next
End Sub

Select Col A and Col B, then run the macro.
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"paul c" wrote:

I have a list with two text columns. I want to identify the rows where the
cells share a common word. For example,
Fujitsu Consulting in col A and Software Engineer in col B would not share a
common word but
Starbucks in col A and Starbucks Barista in col B would share a common word.



Ashish Mathur[_2_]

Determine if 2 cells share a common word
 
Hi,

Let's say the entry is in A4:B4 and then goes downwards. Click on cell A4
and go to Conditional formatting. Write the following formula in
conditional formatting

=OR(ISNUMBER(SEARCH($A4,$B4)),ISNUMBER(SEARCH($B4, $A4)))

Select a format colour and click on OK. This will highlight all those
records (both columns), where the entry is found in the other column.

However please note that if one column has starbuck and the other has
starbucks, it will highlight both entries.

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"paul c" wrote in message
...
I have a list with two text columns. I want to identify the rows where
the
cells share a common word. For example,
Fujitsu Consulting in col A and Software Engineer in col B would not share
a
common word but
Starbucks in col A and Starbucks Barista in col B would share a common
word.




All times are GMT +1. The time now is 11:13 PM.

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