ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Between/ range function (https://www.excelbanter.com/excel-discussion-misc-queries/24074-between-range-function.html)

sanpanico

Between/ range function
 
How could I write a function that would return a number in one cell, if a
number in another cell falls between a certain range?

(if A1 is between C1:D1 then E1, else "0")
(if .23 is between .039:.002 then 15, else "0")

Bob Phillips

=IF(AND(A1=C1,A1<=D1),E1,0)

and

=IF(AND(A1=.002,A1<=.039),E1,0)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"sanpanico" wrote in message
...
How could I write a function that would return a number in one cell, if a
number in another cell falls between a certain range?

(if A1 is between C1:D1 then E1, else "0")
(if .23 is between .039:.002 then 15, else "0")




Jake

=if(and(a1<d1,a1c1),e1,"0")

"sanpanico" wrote:

How could I write a function that would return a number in one cell, if a
number in another cell falls between a certain range?

(if A1 is between C1:D1 then E1, else "0")
(if .23 is between .039:.002 then 15, else "0")


Rick via OfficeKB.com

Use the "if" function. If your value in cell B1 is equal to or between the
value in C1 and the value in D1, you want the value in E1 placed in A1. If
not, you want a text message that indicates your value to be above or below
the range, such as "value BELOW range" or "value ABOVE range" to appear in
A1. If that is want you want, the formula in cell A1 should read as
follows:

=if(B1=C1,if(B1<=D1,E1,"value BELOW range"),"VALUE above RANGE")

In real talk is says 'if B1 is greater than or equal to C1, and if B1 is
less than or equal to D1, then enter the value in E1 in cell A1. If not
enter the appropriate message as to it being either above or below the
range. Note that the text string must be in quotes. You can use the same
message or different messages in the two text strings, or if you want the
cell (A1) to be blank, simply put the quote marks with no space, like "",
in both strings. This formula uses two "if" functions. You can use up to
seven "if" functions in one formula, and use multiple cells to link more
than seven.


All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com