|
下面是我从网上搜索的个人所得税计算函数VBA代码,我自己已经分析过并且修改到自己认为正确的。
Function mytax(x, y)
Dim basicnum As Double, k As Double
Dim upnum As Variant, ratenum As Variant, deductnum As Variant
If y = 0 Then
basicnum = 3500 '中国人起征点
ElseIf y = 1 Then
basicnum = 4800 '外国人起征点
Else: basicnum = Null
End If
k = x - basicnum
upnum = Array(1500, 4500, 9000, 35000, 55000, 80000, 1000000000) '定义累进区间上限
ratenum = Array(0.03, 0.1, 0.2, 0.25, 0.3, 0.35, 0.45) '定义累进税率
deductnum = Array(0, 105, 555, 1005, 2755, 5055, 13505) '定义累进速算扣除数
If k <= 0 Then
mytax = 0
Else:
For i = 0 To UBound(upnum)
If k <= upnum(i) Then
mytax = Round(k * ratenum(i) - deductnum(i), 2)
Exit For
End If
Next i
End If
End Function
|
|