Conditional formatting based on two merged cells content

Steve Jobs

New Member
Joined
May 8, 2015
Messages
41
Hello,

I have two Merged cells with values Cell B8 = 50, 31, 17, 86, 43 and Cell B10 = 50, 31, 86, 43, 41. Now I need a formula or VBA code to highlight another Cell D8 with Red if there is any one common value in both the cells. In this case, 50 and 31 are matching values. I tried using match but does not worked as the cells are merged.

Thanks!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Rijnsent

Well-known Member
Joined
Oct 17, 2005
Messages
1,345
Office Version
  1. 365
Platform
  1. Windows
Hi Steve,

what works for me is an array formula. This assumes maximum 5 numbers in every cell, 2 digits per number, comma & space separated. The formula could be made more flexible, but if your data isn't any more complex, this will do the trick:
Code:
{=MAX(IF(ISERROR(SEARCH(IF(MID(G$3;{1;5;9;13;17};2)<>"";MID(G$3;{1;5;9;13;17};2);"x");$F4));0;1))}
The two cells to compare are G3 and F4. The formula basically cuts the value of G3 into 2 digit chunks (starting at position 1,5,9,13 and 17) and searches for that string in the other cell (F4). It returns a 0 if it's not found and a 1 if it's found. It's an array formula, so you'd have to press CTRL+SHIFT+ENTER to get it to work. My formula has ; as a separator, it might be that you'd have to change that for commas.
Cheers,
Koen
 
Upvote 0

Forum statistics

Threads
1,190,790
Messages
5,982,936
Members
439,808
Latest member
agutosay

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
Top