how to see if any cell in this range equals a value?

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
846
Office Version
  1. 2013
Platform
  1. Windows
I have this formula in one of my worksheets:
=IF(OR(D5=H5,E5=H5,F5=H5,G5=H5,H5=H5,I5=H5),0,"NO")

It's actually even longer and more complicated but this is a good example.
Instead of writing H5 like 5-10 times is there a way to make this easier? Ie if any cell in D5:I5 = H5, 0, else "No"

Thanks!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I have this formula in one of my worksheets:
=IF(OR(D5=H5,E5=H5,F5=H5,G5=H5,H5=H5,I5=H5),0,"NO")
Your code won't work as you want, as a value will ALWAYS equal itself.
You don't want the value you are matching to to be included in your range.

Try this:
Code:
=IF(COUNTIF(D5:G5,H5)+COUNTIF(I5:I5,H5)>0,0,"NO")
 
Upvote 0
You're going to have a problem with the part in red: =IF(OR(D5=H5,E5=H5,F5=H5,G5=H5,H5=H5,I5=H5),0,"NO")
H5 will always be equal to itself.

Oops. It looks like I was a little late in posting.
 
Last edited:
Upvote 0
How about
=IF(COUNTIF(D5:G5,H5),0,"no")
With your description you will always get 0 as H5 will = H5
 
Upvote 0
Couple of things, your formula will always come up as 0 because H5 does equal H5.

If that H5 referring to itself is accurate, you could do this: =IF(CountIF(D5:I5,H5)>0,0,"No")
 
Upvote 0
Another option, assuming you don't want to count H5=H5
=IF(COUNTIF(D5:I5,H5)>1,0,"no")
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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