Function Math Arithmetic Class

IsWithinPlusOrMinusOf

Return True if vCheck is within plus or minus vVariance of vTarget; return False otherwise. Summary: True if vTarget - vVariance <= vCheck <= vTarget + vVariance.

Signature (Visual Basic / VBA)

Public Function IsWithinPlusOrMinusOf( _
      ByVal vCheck As Variant _
    , ByVal vVariance As Variant _
    , ByVal vTarget As Variant _
    ) As Variant

Code Example

    IsWithinPlusOrMinusOf(53, 10, 55) = True
    IsWithinPlusOrMinusOf(45, 10, 55) = True
    IsWithinPlusOrMinusOf(35, 10, 55) = False
    IsWithinPlusOrMinusOf(75, 10, 55) = False

Parameters

Parameter Description
vCheck The value that is checked to see if it is within the range from vTarget plus or minus vVariance. Function returns Null if vCheck is Null or cannot be fixed up to a number.
vTarget The middle of the range of values against which vCheck is compared. Function returns Null if vTarget is Null or cannot be fixed up to a number.
vVariance The middle of the range of values against which vVariance is compared. Function returns Null if vVariance is Null or cannot be fixed up to a number.