How to Allocate Debit Values to Matching References in Excel
Question details
The user needs to allocate or distribute negative debit amounts from Column B to Column C for rows that share the same reference code in Column A.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Processing financial datasets where negative debit values must be mapped and assigned to corresponding duplicate transaction reference codes.
- Observed behavior
- The user wants to populate Column C with the appropriate allocated negative value based on the matching reference code in Column A, but needs the correct formula based on how the amounts should be divided.
Before applying formulas, clarify how you want the debit amounts handled for duplicate references: copied exactly, summed together, or distributed equally among all matching rows.
Sum All Debits for a Matching Reference Using SUMIF
If multiple debit entries exist for the same reference code, you can use the SUMIF function to calculate the total negative amount for that reference in Column C.
The SUMIF function is ideal when you want to aggregate all financial values that share the same identifier. This will ensure that every instance of a reference code in Column A reflects the total accumulated debit in Column C.
Click on the first cell in Column C (e.g., C2) where you want the allocated result to appear.
Type the formula =SUMIF(A:A, A2, B:B). This tells Excel to look through Column A for the value in A2, and sum the corresponding values in Column B.
Press Enter to get the result. Then, double-click the fill handle at the bottom-right corner of cell C2 to drag the formula down to the rest of the column.

Copy the First Matching Debit Value Using VLOOKUP
Use this method if you only need to retrieve the exact debit value associated with the reference code without summing them up.
Distribute Debits Equally Among Matching References
If you have one total debit amount that needs to be divided evenly among all rows sharing the same reference, you can combine SUMIF and COUNTIF.
Allocate and Analyze Debit Values using WPS Spreadsheet
WPS Spreadsheet offers full support for advanced lookup and math functions like SUMIF, COUNTIF, and VLOOKUP, making financial allocations fast, accurate, and completely hassle-free.
- 1. Open your dataset: Launch WPS Spreadsheet and open your financial dataset containing the reference codes and debit values.
- 2. Select the target cell: Click on the cell in Column C where the allocation result should be displayed.
- 3. Insert the function: Navigate to the 'Formulas' tab and click 'Insert Function' to search for SUMIF or VLOOKUP, or simply type the formula directly into the cell.
- 4. Define the criteria: Set your lookup range (Column A), your specific criteria (the reference cell), and the sum range (Column B).
- 5. Auto-fill the column: Press Enter, then double-click the bottom-right corner of the cell to automatically fill the formula down the entire column.

Frequently Asked Questions
Why is my formula returning an #N/A error when matching references?
An #N/A error typically occurs if the reference code in Column A does not exist in your lookup range, or if there are hidden characters like leading/trailing spaces. Use the TRIM function or ensure exact text matches to resolve this.
Can I allocate values only if they are negative?
Yes. You can use the SUMIFS function to add multiple criteria. For example, using the formula =SUMIFS(B:B, A:A, A2, B:B, "<0") will strictly sum values that are less than zero for that specific reference.
How do I highlight rows that have duplicate reference codes?
To easily spot repeating reference codes, select Column A, go to the Home tab, click on Conditional Formatting, choose Highlight Cells Rules, and select Duplicate Values. This will color-code any references that appear more than once.




