Formula using OR - Would like to set a Range

jase71ds

Board Regular
Joined
Oct 23, 2006
Messages
137
Office Version
  1. 365
Platform
  1. Windows
I have a large table...
Each cell in the last column looks back to the left, across its row, and if "X" appears in any of those cells, it will return a value of "Yes".

What I'm currently doing works, but it's barbaric...
= IF (OR (A2="X",B2="X",...M2="X"), "Yes", "")

I'd like to set a simple range, like this...
= IF (OR (A2:M2 = "X"), "Yes"), "")
But it returns "#VALUE"

Any ideas on a simpler formula than what I'm currently using? Because it's a pain when I insert new columns in the middle of the table and then have to update the formula.

Thanks.
Jase.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
How about Countif
=IF(COUNTIF(A2:M2,"X"),"Yes","")
 
Upvote 0
How about Countif
=IF(COUNTIF(A2:M2,"X"),"Yes","")

Wow! I learned something!! I've used Countif many times, but I never realized that you could nestle it within an If/Then in order to render a True or False verdict.

Thanks so much : )
 
Upvote 0
Glad to help & thanks for the feedback.

I think that most, if not all, xl functions can be nested
 
Upvote 0
Yes, I knew that functions could be nestled, but what you showed me was that the nestling of COUNTIF changes what it does.
Example1: If cell G1 contains this formula =COUNTIF(A1:F1,"X") and if cells A1, C1,D1, and F1 contain "X", then the formula returns the answer "4". This is what I would expect.
However, what you showed me
Example2: If cell G1 contains this formula = IF(COUNTIF(A1:F1,"X"),"Yes","No") now COUNTIF appears to be telling the IF statement TRUE.
Anyway, I'm not explaining it well. I'll need to ponder this - it's powerful, but not at all intuitive to me.
 
Upvote 0
Not exactly...

COUNTIF is still returning 4

What's happening is that the IF is interpraiting 4 as TRUE
In a nutshel, 0 is FALSE, ANY NON 0 Number is TRUE
 
Last edited:
Upvote 0
Example2: If cell G1 contains this formula = IF(COUNTIF(A1:F1,"X"),"Yes","No") now COUNTIF appears to be telling the IF statement TRUE.
From memory, In logic 0 = False & 1 = true, my assumption is that in xl 0 =false & anything else = true
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,755
Members
449,094
Latest member
dsharae57

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