A= B + or - X amount? in VBA > tolerance??

C

CAA

Hello all (have you got that Friday feeling!?)

I'm trying to compare an amount with another amount which has gon
through a long process of calculation, i cannot use the round functio
in VBA as this rounds my 1.333's to 1, which loses me just short of
every 3 times this happens.

So, is there a procedure i can write (Tolerrance) that i can slip a
the end of a query such as If a = b Tolerrance Then
Bring out the fatted calf, etc.

I know i could opt for: If a < b+1 And a > b+1 Then
Greece up the Monkey

But my dilema is, it's a whopper of a formula as it is, with AND's
Or's Not >'s

How do i go about writing something that will take an argument chrun i
and evalute, or even how do you pass this value to another procedure t
evaluate then pass it back to the point where it left with an A.OK o
NoWay.?

Thanks for looking
CA
 
B

Bob Phillips

Many points here.

You can round to decimal places, so

Round(1.333,2) returns 1.33 not 1, thus you can save the 1 every 3 times.

The tolerance would have to be coded according to your design, with the
rules coded in.

It's easy to pass a value to a function, for example

If ValueOK(1.333) Then
'etc.


Function ValueOK(val) As Boolean
If Round(val,1) > val * .9 Then
ValOK = True
End If
End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
C

CAA

Tom, Excellent answer, As usual

I re read my post and i must of lost the Lid t' Pot
My :- If a < b+1 And a > b+1 , was Totally off the mark, so i'm gla
someone knows their stuff.

At first i couldn't grasp it, a quick look in the VB help opened m
eyes to more mathamatical functions, i've trimmed my code to a nea
Brazillian.

So without further ado, Thankyou very much.
& "Enjoy your weekend"

CA
 
J

Jerry W. Lewis

Assumes the OP has Excel 2000 or later.

Application.Round() works in any version with VBA.

Jerry
 
Top