conditional formatting based upon info in another cell

jokkebal

New Member
Joined
Jun 26, 2014
Messages
18
Column A contains cells with various texts. This can be in A1 : "customer needs a switch", in A2 "this is a new customer", in A3 "the switch is broken", in A4 "I switched to another system" etc.
In cell B1, I enter a word, e.g. "switch".
Based upon this info in B1, I want all cells in column A, containing the word "switch" to highlight, wherever it is within the cell.
So, in the example, cells A1, A3 and A4 would light up.
Optionally, I also would like cell A4 not to light up because it does not contain the identical word as a whole).

How do I enter this in conditional formatting ?

Thanks,
Josse.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
First scenario, select A1:A?? and apply the Conditional Formatting formula rule shown.

Excel Workbook
AB
1customer needs a switchswitch
2this is a new customer
3the switch is broken
4I switched to another system
5
CF1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A11. / Formula is =SEARCH(B$1,A1)Abc




For the second scenario:

Excel Workbook
AB
1customer needs a switchswitch
2this is a new customer
3the switch is broken
4I switched to another system
5
CF2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A11. / Formula is =SEARCH(" "&B$1&" "," "&A1&" ")Abc
 
Upvote 0
Dear Peter,

This works perfectly well, many thanks for the totally correct and very clear instructions !
Josse.
 
Upvote 0
Code:
[TABLE]
<tbody>[TR]
[TD]Formula is =SEARCH(" "&B$1&" "," "&A1&" ")
[/TD]
[/TR]
</tbody>[/TABLE]
Peter,
I was wondering how to account for the instance in which the phrase ends with "swtich" (given that that they want to nor return "switched"). Pretty clever!
 
Upvote 0
switchswitch switch switch
a switch1
customer0
mend switch1
switched off0
red switch1
switchless circuit0
the first switch in the header is just the word switch
the second one has a blank at the end
the third one has a blank before it
the last one has blanks at either end
easy to use the ones in column H to drive conditional formatting
formula giving first 1 is
=IF(IF(ISERROR(SEARCH(C$1,A2)),0,1)+IF(ISERROR(SEARCH(D$1,A2)),0,1)+IF(ISERROR(SEARCH(E$1,A2)),0,1)>0,1,0)

<colgroup><col><col span="14"></colgroup><tbody>
</tbody>
 
Upvote 0
Dear Peter,

This works perfectly well, many thanks for the totally correct and very clear instructions !
Josse.
Glad it helped. Thanks for letting us know.

Note that it would not highlight a cell that contained "customer needs a switch." as punctuation often foils attempts like this.

Having thought about it some more, you could also try this which highlights provided there is either nothing or a non-letter before and after the word of interest.

Excel Workbook
AB
1customer needs a switch.switch
2this is a new customer
3the switch is broken
4I switched to another system
5The word "switch" is in this
6Switch
7Switch-back
8Test for suffix like unswitch
9Don't touch the switch!
10
CF3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A11. / Formula is =AND(ABS(77.5-CODE(MID(UPPER(1&A1),SEARCH(B$1,A1),1)))>13,ABS(77.5-CODE(MID(UPPER(A1&1),SEARCH(B$1,A1)+LEN(B$1),1)))>13)Abc
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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