![]() |
Multiple OR function
Is there some way to consolidate a function such as this:
=IF(OR(A1=5,B1=5,C1=5,D1=5,E1=5),5,0)? I want to see if any one of a non-contiguous range of cells is equal to a fixed value. I would like to input the fixed value only one time into the function if possible. Thanks. |
In your example you aren using a contiguous range, if that's the case use
=(COUNTIF(A1:E1,5)0)*5 if you really meant non-contiguous range as in A1, C1, E4 etc you can select all cells in question (hold down ctrl while selecting them) then do insertnamedefine and name them to let's say MyRange, then you can use =(SUMPRODUCT(--(LARGE(MyRange,ROW(INDIRECT("1:"&COUNT(MyRange)))) =5))0)*5 note that the latter will return an error if all cells are blank or if it no numbers in the cells Regards, Peo Sjoblom "Scott P" wrote: Is there some way to consolidate a function such as this: =IF(OR(A1=5,B1=5,C1=5,D1=5,E1=5),5,0)? I want to see if any one of a non-contiguous range of cells is equal to a fixed value. I would like to input the fixed value only one time into the function if possible. Thanks. |
=IF(SUMPRODUCT(--(A1:A5=5)),5,0)
or =SUMPRODUCT(--(A1:A5=5))*5 HTH Jason Atlanta, GA -----Original Message----- Is there some way to consolidate a function such as this: =IF(OR(A1=5,B1=5,C1=5,D1=5,E1=5),5,0)? I want to see if any one of a non-contiguous range of cells is equal to a fixed value. I would like to input the fixed value only one time into the function if possible. Thanks. . |
Just another option:
=5*OR(A1:E1=5) Ctrl+Shift+Enter HTH -- Dana DeLouis Win XP & Office 2003 "Scott P" wrote in message ... Is there some way to consolidate a function such as this: =IF(OR(A1=5,B1=5,C1=5,D1=5,E1=5),5,0)? I want to see if any one of a non-contiguous range of cells is equal to a fixed value. I would like to input the fixed value only one time into the function if possible. Thanks. |
Thanks, Dana. I actually found this to work as well based upon your post:
=IF(OR(A1:E1=5),1,0) --- this is entered as an array (CTRL+SHIFT+ENTER) "Dana DeLouis" wrote: Just another option: =5*OR(A1:E1=5) Ctrl+Shift+Enter HTH -- Dana DeLouis Win XP & Office 2003 "Scott P" wrote in message ... Is there some way to consolidate a function such as this: =IF(OR(A1=5,B1=5,C1=5,D1=5,E1=5),5,0)? I want to see if any one of a non-contiguous range of cells is equal to a fixed value. I would like to input the fixed value only one time into the function if possible. Thanks. |
Scott P wrote: Thanks, Dana. I actually found this to work as well based upon your post: =IF(OR(A1:E1=5),1,0) --- this is entered as an array (CTRL+SHIFT+ENTER) [...] If that's what you want, the following would be less costly: =--ISNUMBER(MATCH(5,A1:E1,0)) |
All times are GMT +1. The time now is 07:24 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com