Verifying if text from one cell contained is contained in text in another cell

TrapHouse

New Member
Joined
Jun 22, 2012
Messages
1
Is there a way to verify whether or not the text in a cell in a column with first names is contained in text with a column with full names?

eg. verifying whether or not "WILLIAM" in an arbitrary cell, a2, is contained in "William Smith" in f2 and so forth
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Is there a way to verify whether or not the text in a cell in a column with first names is contained in text with a column with full names?

eg. verifying whether or not "WILLIAM" in an arbitrary cell, a2, is contained in "William Smith" in f2 and so forth

This snippet would use the value in A2 to look at F2 and see it that same string appeared anywhere in that cell.

Code:
Sub isBill()
Dim sh As Worksheet, myVal
Set sh = Sheets(1)
myVal = sh.Range("A2")
If InStr(sh.Range("F2").Value, myVal) > 0 Then
MsgBox "String Found"
Else
MsgBox "String Not Found"
End If
End Sub
Code:
 
Last edited:
Upvote 0
Hi,
This can be made to return the name found, or anything you want, but without more to go on, (and for a formula approach) here's something you can try:
Code:
=IF(COUNTIF(F2,"*"&A2&"*")>0,"Found","Not-Found")
It's only one way to skin this particular cat.

Hope it helps.
 
Upvote 0

Forum statistics

Threads
1,203,174
Messages
6,053,925
Members
444,694
Latest member
JacquiDaly

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