ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Comparing Values from 2 cells (https://www.excelbanter.com/excel-programming/348021-comparing-values-2-cells.html)

reggie

Comparing Values from 2 cells
 
I working on a form where there is a Value in cell B89 and there is a value
in cell F90. I need excel to determin if the value in F90 falls in the range
of the value for cell B89..

example:

cell B89 value = 3.5 - 5.0 (not minus sign) this values also changes...
Cell F90 value (user entered value) = 4.5

i need excel to see if 4.5 falls in the range of 3.5 - 5.0

Toppers

Comparing Values from 2 cells
 
Reggie,

Try this:

e.g in Cell A1 put "=IsInRange(B89,F90)" (no quotes) and function will
return TRUE or FALSE.

in VBA:
Dim Check as boolean
Check=isInRange(Range("B89"),range("F90"))

Function IsInRange(ByRef rng As Range, cv As Range) As Boolean
Dim lv As Double, uv As Double
lv = CDec(Left(rng.Value, InStr(1, rng, "-") - 1))
uv = CDec(Right(rng.Value, InStrRev(rng, "-") - 1))
If cv.Value = lv And cv.Value <= uv Then
IsInRange = True
Else
IsInRange = False
End If
End Function

HTH

"Reggie" wrote:

I working on a form where there is a Value in cell B89 and there is a value
in cell F90. I need excel to determin if the value in F90 falls in the range
of the value for cell B89..

example:

cell B89 value = 3.5 - 5.0 (not minus sign) this values also changes...
Cell F90 value (user entered value) = 4.5

i need excel to see if 4.5 falls in the range of 3.5 - 5.0


Charlie

Comparing Values from 2 cells
 
Obviously you mean the value in B89 is a string containing two numbers
separated by a space-dash-space. Those two numbers really should be put into
two individual cells, but if this cannot be done then...(here goes)...try
this crazy formula:

=IF(AND(F90=VALUE(LEFT(B89,FIND(" -
",B89)-1)),F90<=VALUE(RIGHT(B89,LEN(B89)-FIND(" - ",B89)-2))),"YES","NO")

"Reggie" wrote:

I working on a form where there is a Value in cell B89 and there is a value
in cell F90. I need excel to determin if the value in F90 falls in the range
of the value for cell B89..

example:

cell B89 value = 3.5 - 5.0 (not minus sign) this values also changes...
Cell F90 value (user entered value) = 4.5

i need excel to see if 4.5 falls in the range of 3.5 - 5.0



All times are GMT +1. The time now is 12:08 PM.

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