VBA代码实例---个人所得税计算

¤工资计算原理¤

根据最新的个人所得税计算方法,其计算方法如下:

应纳个人所得税=应纳所得税额×使用税率-速算扣除数

VBA代码实例---个人所得税计算_第1张图片

¤代码实现公式¤

使用select case语句,根据金额匹配税率和速算扣除数;

¤代码示例¤

Option Explicit

Sub 个人所得税()

    Dim Income As Double
    Dim taxRate As Double
    Dim deduct As Double
        
    Dim i As Integer
    For i = 2 To Range("A1").CurrentRegion.Rows.Count
    
        Income = Range("A" & i).Value
        Select Case Income - 3500
            Case Is <= 0
                taxRate = 0
                deduct = 0
            Case 0 To 1500
                taxRate = 0.03
                deduct = 0
            Case 1500 To 4500
                taxRate = 0.1
                deduct = 105
            Case 4500 To 9000
                taxRate = 0.2
                deduct = 555
            Case 9000 To 35000
                taxRate = 0.25
                deduct = 1005
            Case 35000 To 55000
                taxRate = 0.3
                deduct = 2755
            Case 55000 To 80000
                taxRate = 0.35
                deduct = 5505
            Case Is > 80000
                taxRate = 0.45
                deduct = 13505
            End Select
        Range("B" & i).Value = taxRate
        Range("C" & i).Value = deduct
        Range("D" & i).Value = WorksheetFunction.Round(Income * taxRate - deduct, 2)
        
    Next i

End Sub


你可能感兴趣的:(VBA代码实例---个人所得税计算)