Question about using the IF function to display matching text/pattern matching

mikelopez

Board Regular
Joined
Sep 9, 2013
Messages
58
Hello everyone.

I just a have a general question about using the IF function to display matching names.

My spreadsheet looks like this

edcoronado
edcoronado123
joeljoelsmith
don schmitdonschimt4523
dansmithdan jones
The above is in the A and B cells respectively.

What I want to know is what would be the proper syntax formula I would use if I wanted to match and display the names that are similar to each other?

What I am trying to create and accomplish is a formula using the IF function where if the name in A1 is similar or the exact name in B1,( as well as A2 and B2 respectively) I want the function to grab the text that is similar and display it in column D. I think I can use the IF function but I am not sure.

Any help would be greatly appreciated. THE FORMULA I AM TRYING TO USE IS
=IF(A1=B1, " ", "9999"

Where if the letters are similar I want the text that is similar to be displayed and if it is not, I want 9999 to appear.

Again any help would be greatly appreciated.

<tbody>
</tbody>
 
Last edited:
Yep just switch the cells and it should be fine.

=IF(IF(ISERROR(SEARCH("*"&A1&"*",B1)),"",SEARCH("*"&A1&"*",B1))=1,A1,"") now becomes

=IF(IF(ISERROR(SEARCH("*"&B1&"*",A1)),"",SEARCH("*"&B1&"*",A1))=1,B1,"")

"*" - acts as a wildcard so your saying anything before or after as long as the cell contains the text johnsmith.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I switched the cells and it didn't work. I didn't get johnsmith.

here is what I have:
johnsmith1882 in cell A7
johnsmith in cell B7.

I tried the command function you told me to do:

=IF(IF(ISERROR(SEARCH("*"&B7&"*",A7)),"",SEARCH("*"&B7&"*",A7))=1,B7,"")

and it didn't work.

Do you have any other suggestions and can this command work with other cell numbers?
 
Upvote 0
Is there something wrong that you think I might be doing on my end. I did copy and paste this code into C7 for the 7th row and it didn't work.
 
Upvote 0
Strange works for me and ISERROR is excel 2003 compatible.

What error does your cell show?

Excel 2010
A
B
C
johnsmith1882
johnsmith
johnsmith

<TBODY>
[TD="align: center"]7
[/TD]

</TBODY>
Sheet4

[TABLE="width: 85%"]
<TBODY>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<TBODY>[TR="bgcolor: #dae7f5"]
[TH="width: 10"]Cell
[/TH]
[TH="align: left"]Formula
[/TH]
[/TR]
[TR]
[TH="width: 10, bgcolor: #dae7f5"]C7
[/TH]
[TD="align: left"]=IF(IF(ISERROR(SEARCH("*"&B7&"*",A7)),"",SEARCH("*"&B7&"*",A7))=1,B7,"")
[/TD]
[/TR]
</TBODY>[/TABLE]

[/TD]
[/TR]
</TBODY>[/TABLE]
 
Upvote 0
The error that it shows me is that when I copied and pasted the input you gave me just now. Nothing shows up in cell C7. I don't know why.
 
Upvote 0
Try

=IF(IF(ISERROR(SEARCH("*"&B7&"*",A7)),"TEST",SEARCH("*"&B7&"*",A7))=1,B7,"TEST")

Does TEST at lease show up instead of nothing?

on your data set, do a =TRIM(CLEAN(cell)) for all your cells, you might have some hidden spaces.
 
Upvote 0
Good morning. Sorry to keep bothering you like this but to answer your question yes TEST at least shows up instead of nothing.

How do I do the =TRIM(CLEAN(cell))) for my cells? Do I highlight the cell C7 and then do the command.
 
Upvote 0
Create a new column next to the lookup values. So if the lookup value is in column A. In any other column type =TRIM(CLEAN(A1) and drag down. Thsi will clean out the cells in column A that might have trailing spaces or hidden spaces.


Excel 2010
AB
1dsafdsfdsafdsf
2dsafdsfdsafdsf
3sdafsdaf
4sdafsdaf
5dsafdsfdsafdsf
6ff
7asdfasdf
8dsafdsfdsafdsf
9ff
10sdfsdf
11fsdfsd
Sheet1
Cell Formulas
RangeFormula
B1=TRIM(CLEAN(A1))
B2=TRIM(CLEAN(A2))
B3=TRIM(CLEAN(A3))
B4=TRIM(CLEAN(A4))
B5=TRIM(CLEAN(A5))
B6=TRIM(CLEAN(A6))
B7=TRIM(CLEAN(A7))
B8=TRIM(CLEAN(A8))
B9=TRIM(CLEAN(A9))
B10=TRIM(CLEAN(A10))
B11=TRIM(CLEAN(A11))
 
Upvote 0
Once this is done do I then delete what is in column A and use what is in Column B as what is being looked up or do I leave it the same and use the inverted cell formula you told me about all over again?
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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