Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All:
hoping that someone can help. I am a newbie at vba only started a week ago. I wrote the following code but it gives me an incorrect result ie tax payable for persons with income greater than $30,000 per year. The problem seem to be in the case construction at the end of the script but I can't seem to sole it. Sub taxation5() TotalIncome = InputBox("Please enter Total Salary for January 2005") projectedsalary = TotalIncome * 12 MsgBox (" Your projected total income for 2005 will be " & Format(projectedsalary, "$#,##0.00")) Select Case projectedsalary Case Is <= 30000 personalallowance = 30000 Case Is 35000 personalallowance = 25000 Case 30001 To 35000 personalallowance = 30000 - (TotalIncome - 30000) End Select MsgBox ("your personal allowance for 2005 will be " & Format(personalallowance, "$#,##0.00")) Td1deductions = InputBox("Please enter other TD1 deductions for 2005 excluding personal allowance") chargeableincome = projectedsalary - personalallowance - Td1deductions If chargeableincome < 0 Then chargeableincome = 0 chargeableincome = MsgBox("Your chargeable income for the year will be " & Format(chargeableincome, "$#,##0.00") _ & " and no tax payable ") chargeableincome = MsgBox("Your chargeable income for the year will be " & Format(chargeableincome, "$#,##0.00")) Select Case chargeableincome Case 30000 To 50000 taxation = chargeableincome * 0.25 Case Is 50000 taxation = 12500 + (chargeableincome - 50000) * 0.3 End Select MsgBox (" Taxes of " & Format(taxation, "$#,##0.00") & " is tax payable to the Board of Inland Revenue") End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Case without Select Case error problem | Excel Discussion (Misc queries) | |||
Simplify Code - Select Case | Excel Programming | |||
2 x Case // Error why ? | Excel Programming | |||
Code for Case & Number format | Excel Programming | |||
Proper case code not working right | Excel Programming |