How to reply a TRUE/False via VBA

F

FARAZ QURESHI

How to develop a simple UDF like:
=Correct(Salary,Tax)
so as to return a TRUE if the argument Tax = Salary * 10%?
Thanx!
 
C

Chip Pearson

Insert a module to the VBA project and use code like:

Function Correct(Salary As Double, Tax As Double) As Boolean
If Abs(Tax - (Salary * 0.1)) < 0.001 Then
Correct = True
Else
Correct = False
End If
End Function

The function considers a difference between Tax and Salary * 10% of
less than 0.001 to mean equal. Due to the intrinsic rounding, it is
likely that the two values may be slightly different when they should,
in fact, be considered equal.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
J

Joel

Function Correct(Salary,Tax)
if Tax = (.1 * Salary ) then
Correct = True
else
Correct = False
end if
End Function
 
B

Bob Phillips

Function Correct(Salary As Double, Tax As Double) As Boolean
Correct = Abs(Tax - (Salary * 0.1)) < 0.001
End Function
 
Top