Sunday, August 9, 2015

How to calculate Tax by Excel using custom functions

##Instruction of the tax calculation

If the salary is less than 50k your tax will be 5%;
If the salary is more than and equal 50k and less than 120k tax will be 20%;
If the salary is more than and equal to 120k tax will be 25%;


###for excel with space
IF (A1 < 50000, A1 * .05,
IF( AND(A1 >= 50000, A1 < 120000), A1 * .20,
IF( A1 >= 120000, A1 * .25

) ) )

###for excel without space so that I can use directly 
=IF(A1<50000,A1*0.05,IF(AND(A1>=50000,A1<120000),A1*0.20,IF(A1>=120000,A1*0.25)))

###for vb script function in excel 

Function GP(Salary as Double)
If Salary < 50000 Then
GP = Format((Salary * .05) , "0.00");
ElseIf Salary >= 50000 AND Salary < 120000 Then
GP = Format((Salary * 20) , "0.00");
ElseIf 
GP = Format((Salary * .05) , "0.00");
End If
End Function

No comments:

Post a Comment

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }