Skip to content

Instantly share code, notes, and snippets.

@zhimiaoli
Last active December 29, 2015 09:49
Show Gist options
  • Save zhimiaoli/7653127 to your computer and use it in GitHub Desktop.
Save zhimiaoli/7653127 to your computer and use it in GitHub Desktop.
计算个人所得税的自定义函数
Function tax(salary As Double) As Double
Application.Volatile '让Excel频繁计算,避免更改工资还不更新个税
'''个人所得税计算函数
If salary < 3500 Then
tax = 0
Else
g = salary - 3500
Select Case g
Case Is <= 1500
tax = Round(g * 0.03, 2)
Case Is <= 4500
tax = Round(g * 0.1, 2) - 105
Case Is <= 9000
tax = Round(g * 0.2, 2) - 555
Case Is <= 35000
tax = Round(g * 0.25, 2) - 1005
Case Is <= 55000
tax = Round(g * 0.3, 2) - 2755
Case Is <= 80000
tax = Round(g * 0.35, 2) - 5505
Case Is > 80000
tax = Round(g * 0.45, 2) - 13505
End Select
End If
End Function
@zhimiaoli
Copy link
Author

使用方法

  1. 录制一个宏,选择保存到个人宏工作簿,不要录制任何内容,这样会创建一个personal.xlsb
  2. 将上面的代码贴到personal.xlsb的一个模块中
  3. 输入函数的方法,在单元格中输入=,然后在公式栏中点击Fx,在类别中选择用户定义,然后就可以看到自定义的函数了。
  4. 选择定义的tax函数,选择对应需要的参数。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment