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:
[TABLE="width: 500"]
<tbody>[TR]
[TD]01[/TD]
[TD]ABC_01_XXX[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]22[/TD]
[TD]ABC_22_XXX[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]ABC_88_XXX[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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