Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to quickly calculate the overtime and payment in Excel?

Author Sun Last modified

In many workplaces, tracking employee work hours, especially overtime, is essential for accurate payroll calculation and compliance with regulations. Suppose you have a table recording a worker’s clock-in, lunch break, and clock-out times. You want to quickly calculate the overtime hours and corresponding payments for each day, as demonstrated in the screenshot below. Effective calculation not only saves time but also reduces the risk of manual errors, which is crucial when summarizing data for multiple staff or payroll periods.
calculate the overtime and payment

Calculate overtime and payment

VBA Macro for Batch Overtime/Payment Calculation

Using Pivot Tables for Summary Analysis


arrow blue right bubble Calculate overtime and payment

You can efficiently determine the overtime hours and corresponding payments in Excel using built-in formulas. This approach is suitable for individual worker records or smaller datasets where you need straightforward calculations. Here is a step-by-step guide:

1. First, calculate the regular working hours for each day. Click cell F2 and enter the following formula:

=IF((((C2-B2)+(E2-D2))*24)>8,8,((C2-B2)+(E2-D2))*24)

Press Enter, and then drag the AutoFill handle down to copy the formula to other rows. This will display the regular working hours for each day in column F.
Apply a formula to display the regular working hour

2. Next, calculate the overtime hours. In cell G2, enter the formula below:

=IF(((C2-B2)+(E2-D2))*24>8, ((C2-B2)+(E2-D2))*24-8,0)

After pressing Enter, drag the formula down to fill the overtime column for all rows. Each day's overtime will be calculated in column G.
 Apply a formula to calculate the overtime

In these formulas:

  • B2: Start of work (clock-in time)
  • C2: Start of lunch break
  • D2: End of lunch break
  • E2: End of work (clock-out time)
  • The calculation assumes a standard working day of 8 hours; you can adjust '8' in the formula and time references as needed for your policies.
Tip: Ensure time values are correctly formatted in Excel (e.g., hh:mm).

3. To summarize total regular hours and overtime hours for the week, select cell F8 and enter:

=SUM(F2:F7)

Then, drag this formula to cell G8 to get total overtime hours.
 apply a formula to get total regular hours and overtime hours

4. Calculate payments for regular hours and overtime in designated cells. For example, in cell F9 to calculate regular wage, enter:

=F8*I2

Likewise, in cell G9 for overtime wage, enter:

=G8*J2

Here, I2 and J2 should contain the respective hourly rates for regular and overtime work.
use formulas to calculate the payment for regular hours and overtime

To get the total payment for both regular and overtime, use a simple sum in cell H9:

=F9+G9

This final result represents the total compensation for the period under review, combining regular pay and extra overtime pay.
 apply a formula to calculate the total payments

This formula-based method is straightforward and quick for daily or weekly calculations and is easily adaptable if work schedules or overtime standards change. However, for large numbers of employees or advanced reporting needs, other Excel features or automation may be more efficient.

  • Advantages: Simple, no coding knowledge required, easy to maintain for small datasets.
  • Limitations: Manual setup for each worker/table, formula maintenance needed if table structure changes, not optimal for very large datasets.

If your dataset grows or you need to calculate overtime/payment for many workers or over different periods, consider automating this process or using Excel's built-in analysis tools. See options below:

arrow blue right bubble VBA Macro for Batch Overtime/Payment Calculation

When working with large datasets involving multiple workers, sheets, or periods—where filling formulas manually is inefficient—you can use a VBA macro to automate the entire calculation. This method streamlines repetitive processing, especially when dealing with complex data structures or frequent data imports.

Scenario: You have a table with columns for employee, work start, lunch start, lunch end, work end, and you wish to batch calculate regular hours, overtime, and payment.

Note: Before running, save your workbook and ensure macros are enabled. Make a backup to avoid accidental data loss during testing or initial runs.

1. Click Developer Tools > Visual Basic. In the Microsoft Visual Basic for Applications window, click Insert > Module, then copy and paste the following code into the Module:

Sub BatchOvertimeCalculation()
    Dim ws As Worksheet
    Dim i As Long
    Dim lastRow As Long
    Dim regHourCol As String, overtimeCol As String, payCol As String
    Dim startCol As String, lunchStartCol As String, lunchEndCol As String, endCol As String
    Dim regHourlyRate As Double, overtimeHourlyRate As Double
    
    On Error Resume Next
    
    regHourCol = InputBox("Enter column letter for Regular Hour (output):", "KutoolsforExcel", "F")
    overtimeCol = InputBox("Enter column letter for Overtime (output):", "KutoolsforExcel", "G")
    payCol = InputBox("Enter column letter for Payment (output):", "KutoolsforExcel", "H")
    startCol = InputBox("Enter column letter for Work Start:", "KutoolsforExcel", "B")
    lunchStartCol = InputBox("Enter column letter for Lunch Start:", "KutoolsforExcel", "C")
    lunchEndCol = InputBox("Enter column letter for Lunch End:", "KutoolsforExcel", "D")
    endCol = InputBox("Enter column letter for Work End:", "KutoolsforExcel", "E")
    
    regHourlyRate = Application.InputBox("Enter hourly rate for regular hours:", "KutoolsforExcel", 15, Type:=1)
    overtimeHourlyRate = Application.InputBox("Enter hourly rate for overtime:", "KutoolsforExcel", 22.5, Type:=1)
    
    Set ws = Application.ActiveSheet
    lastRow = ws.Cells(ws.Rows.Count, startCol).End(xlUp).Row
    
    For i = 2 To lastRow
        Dim totalHours As Double, regHours As Double, overtimeHours As Double
        
        totalHours = ((ws.Range(lunchStartCol & i) - ws.Range(startCol & i)) + _
                      (ws.Range(endCol & i) - ws.Range(lunchEndCol & i))) * 24
        
        If totalHours > 8 Then
            regHours = 8
            overtimeHours = totalHours - 8
        Else
            regHours = totalHours
            overtimeHours = 0
        End If
        
        ws.Range(regHourCol & i).Value = regHours
        ws.Range(overtimeCol & i).Value = overtimeHours
        ws.Range(payCol & i).Value = regHours * regHourlyRate + overtimeHours * overtimeHourlyRate
    Next i
    
    MsgBox "Batch calculation complete!", vbInformation, "KutoolsforExcel"
End Sub

2. After entering the code, click the Run button button in the VBA toolbar to run the macro. Input the requested information in the dialog boxes (such as which columns contain your time data and payment rates). The macro will automatically fill columns for regular hours, overtime, and total payment for each row.
Troubleshooting: Make sure all time columns have proper Excel time-format. If any cell has invalid or empty data, the macro will skip or may return a '0'. Always check a few rows manually after running the macro for accuracy.

  • Advantages: Extremely efficient for large/complex datasets, eliminates manual copying and formula drag.
  • Limitations: Requires some VBA familiarity, security warning on enabling macros, care needed with referencing correct columns.

Summary suggestions: For daily or one-off calculations, formulas are fast and intuitive. As your overtime calculation task scales to more records or reporting needs become more complex, automating with VBA can significantly reduce manual effort and error. Always double-check for accurate time formatting and, after any solution, verify calculation logic matches your company's overtime policies. If you encounter errors (like #VALUE!), re-examine cell formats or blank entries. Consider maintaining a backup before batch operations.


Add Days, Years, Months, Hours, Minutes, and Seconds to Dates in Excel with Ease

If you have a date in a cell and need to add days, years, months, hours, minutes, or seconds, using formulas can be complicated and hard to remember. With Kutools for Excel’s Date & Time Helper tool, you can effortlessly add time units to a date, calculate date differences, or even determine someone's age based on their birthdate - all without needing to memorize complex formulas.

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in