Function help required... Between funtion

A

Angela

Hello,

I have below formula to calculate wether a number exists between a
start & end serial number.

Start = cell A3
End = cell B3

test value = cell F3

=IF(AND(F3>=A3,F3<=B3),"Yes",IF(AND(F3<=A3,F3>=B3),"Yes","No"))


I want to convert this formula into a function which I can use in
excel/access.

Hope someone can help based on provided formula working.

Thanks.
 
R

Ron Rosenfeld

Hello,

I have below formula to calculate wether a number exists between a
start & end serial number.

Start = cell A3
End = cell B3

test value = cell F3

=IF(AND(F3>=A3,F3<=B3),"Yes",IF(AND(F3<=A3,F3>=B3),"Yes","No"))


I want to convert this formula into a function which I can use in
excel/access.

Hope someone can help based on provided formula working.

Thanks.

=IF(AND(F3>=A3,F3<=B3),"Yes","No")
 
A

Angela

Thanks but I need to have a function like =Between(Number,start,end)
which can give this... just like built-in excel function.
 
R

Ron Rosenfeld

Thanks but I need to have a function like =Between(Number,start,end)
which can give this... just like built-in excel function.


To enter this User Defined Function (UDF), <alt-F11> opens
the Visual Basic Editor. Ensure your project is highlighted
in the Project Explorer window. Then, from the top menu,
select Insert/Module and paste the code below into the
window that opens.

=========================
Option Explicit
Function Between(Number As Double, Bound1 As Double, Bound2 As Double)
As Boolean
Dim LowerLimit As Double
Dim UpperLimit As Double
LowerLimit = IIf(Bound1 <= Bound2, Bound1, Bound2)
UpperLimit = IIf(Bound1 >= Bound2, Bound1, Bound2)
Between = Number >= LowerLimit And Number <= UpperLimit
End Function
===============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top