Excel考勤薪资表怎么自动计算加班?

怎么用excel做考勤薪资表

Sub CalculateOvertime()
Dim lastRow As Long
lastRow = Cells(Rows.Count, “B”).End(xlUp).Row ‘ 获取数据最后一行

For i = 2 To lastRow
    Dim startTime As Date, endTime As Date, overtime As Double
    startTime = Cells(i, "B").Value  ' 上班时间
    endTime = Cells(i, "C").Value  ' 下班时间

    If (endTime - startTime) * 24 > 9 Then
        overtime = (endTime - startTime) * 24 - 9
    End If

    Cells(i, "D").Value = overtime '加班时间
Next i

End Sub

利唐i人事HR社区,发布者:hiHR,转转请注明出处:https://www.ihr360.com/hrnews/2024129338.html

(0)
上一篇 2天前
下一篇 2天前

相关推荐