VBA Function Subroutine

mabernathy

New Member
Joined
Mar 13, 2021
Messages
9
Office Version
  1. 2010
Platform
  1. Windows
I need to do the following. I've attached a screenshot of what I have done, but I know it's not correct. Any advice? Thanks.

Write a VBA Function subroutine called Tax that takes a single argument Gross Income of type Currency. It should calculate the tax on any income using the following tax schedule:

If income is less than or equal to $15,000, Tax is $0

If income is greater than $15,000 and less than or equal to $75,000, the tax is 15% of all income greater than $15,000

If income is greater than $75,000, the tax is 15% of all income between $15,000 and $75,000 plus 20% of all income greater than $75,000

Then write a CalcTax subroutine that asks the user for his income, gets the function subroutine to calculate the tax on this income, and reports the tax in a message box.
 

Attachments

  • Capture.PNG
    Capture.PNG
    20.5 KB · Views: 4

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,704
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You should be using:
Code:
If ... Then

ElseIf ... Then

Else

End If

and not separate If statements.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,713
Messages
5,637,936
Members
416,993
Latest member
ant8989

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top