SEARCH function only finds full string, but not substring

richi5000

New Member
Joined
Nov 14, 2016
Messages
8
Hi all,

Background: I was searching for a formula (for conditional formatting) that checks if a specific cell (text format) contains a specific text of an adjunctive cell as a substring. If there is no match, the cells should be highlighted red. As an example:
01ABC_01_XXX
22ABC_22_XXX
01ABC_88_XXX

<tbody>
</tbody>

I want to check if column B contains the content of column A as a substring. So in the example the row 3 should be highlighted.

I've tried
Code:
=ISNUMBER(SEARCH($B$1;$A$1))

This did'nt work. When trying to crack down the issue, I tried parts of the formula to check, what goes wrong.

When I try to search for the substring manually:
Code:
=SEARCH($B$1;"01")
it returns "#VALUE"

Instead, when I try
Code:
=SEARCH($B$1;"ABC_01_XXX")
it works and returns "1"

But shouldn't the search-formula find the substring and return the position of the given text?


Thanks,
Richie
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Looks like you have your arguments switched
Code:
=SEARCH(find_text,within_text)
You want to look for A1 with in B1
Code:
=SEARCH(A1,B1)
 
Upvote 0
Thanks for the fast answer. That was quite easy - works great. Obviously that was a great example of monday morning sleep deprivation :oops:

btw..the final code for the conditional formatting is:
Code:
=NOT(ISNUMBER(SEARCH($A1;$B1)))
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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