logo
search
Formula Errors

How to Subtract Leave Hours from a Specific Balance in Excel

Ayan MasoodAyan Masood Sep 27, 2026 869 views

Question details

The user needs an Excel formula to subtract logged leave hours exclusively from the correct leave balance by matching specific leave codes.

How to Subtract Leave Hours from the Correct Balance Using Excel Formulas
Product
Excel
Device & OS
not provided
Scenario
Tracking employee leave and deducting hours from appropriate balances based on leave category codes like 'CP', while allowing earned hours to be added.
Observed behavior
Requires a dynamic formula to identify the correct leave code criteria, sum the logged hours, and subtract them from the initial balance without mixing different leave types.
Before you start

Ensure that the leave codes entered in your daily tracking columns match exactly with the codes listed in your summary table to prevent calculation errors.

Solution 1Recommended

Use SUMIFS and SUBSTITUTE to Deduct Leave Hours

This method utilizes SUMIFS to calculate hours based on specific leave codes and subtracts the total from your starting balance.

The SUMIFS function is ideal for summing values that meet specific criteria. By nesting the SUBSTITUTE function, you can ensure that any accidental formatting characters (like an equals sign) in your criteria cell are removed before the match is evaluated.

1
Select the target balance cell

Click on the cell in your summary table where you want the updated leave balance to be displayed (for example, cell J12).

2
Enter the SUMIFS formula

In the formula bar, type `=J5-SUMIFS(F$6:F$45,D$6:D$45,SUBSTITUTE(I12,"=",""))`. Here, J5 represents the initial balance, F$6:F$45 is the range containing recorded hours, D$6:D$45 is the range containing the leave codes, and I12 is the specific leave code you want to match.

3
Apply the formula to other balances

Press Enter to calculate the result. Then, click the small square at the bottom-right corner of cell J12 and drag the fill handle down to apply the formula to the remaining rows.

Use SUMIFS and SUBSTITUTE to Deduct Leave Hours
Absolute References: Using dollar signs ($) in the formula creates absolute references, which locks the data ranges so they don't shift when you drag the formula down to other rows.
Manage Spreadsheets Effectively

Easily Calculate Leave Balances in WPS Spreadsheet

WPS Office provides a powerful, free spreadsheet application that is fully equipped to handle advanced data tracking. You can effortlessly manage team attendance, calculate complex leave balances, and utilize dynamic formulas seamlessly.

  1. 1. Open your tracking sheet in WPS: Launch WPS Spreadsheet and open your existing leave tracking document.
  2. 2. Input the calculation formula: Select your balance cell and type the SUMIFS formula to track your specific leave codes.
  3. 3. Fill the formula down: Use the drag-and-fill handle to quickly copy the calculation to all other employees.
  4. 4. Save as Excel format: Save your document in .xlsx format to share it without compatibility issues with Microsoft Excel users.
Fully supports advanced Excel formulas like SUMIFS, SUBSTITUTE, and VLOOKUP.Seamless compatibility with Microsoft Excel (.xlsx) file formats to ensure exact data representation.Free, lightweight, and features an intuitive tabbed interface for easier multitasking.Provides a wide range of free built-in templates for attendance and HR management.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my SUMIFS formula returning zero when matching leave codes?

This usually happens if the criteria text (like the leave code) has trailing or leading spaces that prevent an exact match with the evaluation range. You can use the TRIM function on your cells or ensure data validation is applied to fix space discrepancies.

What does the SUBSTITUTE function do in this specific formula?

The SUBSTITUTE function, written as SUBSTITUTE(I12,"=",""), removes any accidental equals signs from the criteria cell. This ensures the SUMIFS function interprets the criteria as pure text (like "CP") instead of a logical operator.

Can I track multiple leave types in a single logging column?

Yes, by assigning unique codes to each leave type (e.g., "CP" for casual leave, "SL" for sick leave) in the code column, the SUMIFS formula can filter through the list and sum the hours for each specific leave type independently.