To sum values found with VLOOKUP, you typically use SUMIF or SUMIFS instead, because VLOOKUP returns only the first match. However, if you need to sum multiple values from a lookup table, use SUMPRODUCT with a condition, or combine SUM with VLOOKUP when you want to add the result of several separate lookups (e.g., =VLOOKUP(A2,Table1,2,0)+VLOOKUP(B2,Table1,2,0)).
Why VLOOKUP Alone Can’t Sum
VLOOKUP is designed to find one value in the leftmost column of a table and return a corresponding value from a column to the right. It stops at the first exact match (or approximate match if you use TRUE). If your data has duplicate lookup values, VLOOKUP will only return the first occurrence—it will not add up all matching rows. For example, if you have a list of sales by product and product “Apple” appears three times, =VLOOKUP("Apple", A2:B10, 2, FALSE) returns only the first sale amount, not the total.
To sum all matches, you need a function that iterates over the entire range. The most common solution is SUMIF, which sums values in a range that meet a single condition. For multiple conditions, use SUMIFS. These functions are the direct replacement for “VLOOKUP and SUM” when you want to aggregate.
Using SUMIF Instead of VLOOKUP + SUM
Suppose you have a product list in column A (A2:A100) and sales amounts in column B (B2:B100). To sum all sales for “Apple”, use:
=SUMIF(A2:A100, "Apple", B2:B100)
This sums every cell in B2:B100 where the corresponding cell in A2:A100 equals “Apple”. If you want to sum based on a cell reference (e.g., E1 contains “Apple”), use =SUMIF(A2:A100, E1, B2:B100).
For multiple criteria—say, sum sales for “Apple” in the “North” region, with region in column C—use SUMIFS:
=SUMIFS(B2:B100, A2:A100, "Apple", C2:C100, "North")
Note that SUMIFS always has the sum range first, unlike SUMIF.
When You Might Actually Use VLOOKUP with SUM
There are legitimate cases where you combine SUM and VLOOKUP directly:
- Adding results from multiple lookups: If you need the total of several specific items, you can add two VLOOKUPs:
=VLOOKUP("Apple", A2:B10, 2, FALSE) + VLOOKUP("Banana", A2:B10, 2, FALSE) - Summing across columns: If you want to sum the values from multiple columns for a single lookup key, use
=SUM(VLOOKUP("Apple", A2:D10, {2,3,4}, FALSE))—but this requires entering as an array formula in older Excel (Ctrl+Shift+Enter). In Excel 365, it works normally. - Using VLOOKUP inside SUMIF criteria: For example, sum amounts where the product ID matches a lookup from another table:
=SUMIF(A2:A100, VLOOKUP(D1, F2:G10, 2, FALSE), B2:B100)
In most real-world scenarios, though, SUMIF or SUMIFS is simpler and faster.
Using SUMPRODUCT for Advanced Lookup and Sum
If you need to sum values based on a lookup from another table, SUMPRODUCT is a powerful alternative. For example, you have sales data with product codes in A2:A100 and quantities in B2:B100. You also have a price table with codes in D2:D10 and prices in E2:E10. To calculate total revenue, you can use:
=SUMPRODUCT(B2:B100 * VLOOKUP(A2:A100, D2:E10, 2, FALSE))
This works in Excel 365 and Excel 2021 as a dynamic array formula. In older versions, you must enter it with Ctrl+Shift+Enter. The VLOOKUP part returns an array of prices for each code, and SUMPRODUCT multiplies each quantity by its price and sums the results.
Alternatively, use SUMIFS with a helper column that brings in the price via VLOOKUP, but SUMPRODUCT avoids the helper column.
Common Errors and How to Fix Them
- #N/A error: VLOOKUP cannot find the lookup value. Check that the lookup value exists in the first column of the table, and that there are no extra spaces or non-printable characters. Use
TRIMorCLEANon the lookup value. - #VALUE! error: Often occurs when using VLOOKUP inside SUMPRODUCT if the ranges are not the same size. Ensure the lookup array and the sum array have the same number of rows.
- Wrong results with approximate match: If you omit the fourth argument (range_lookup) or use TRUE, VLOOKUP does an approximate match, which can return incorrect values. Always use FALSE for exact matches unless you have sorted data and really need an approximate match.
- SUMIF returns 0: Check that the criteria text matches exactly (case-insensitive but must match spaces). If the sum range is not the same size as the criteria range, adjust it.
VLOOKUP vs. XLOOKUP for Summing
XLOOKUP, available in Excel 365 and Excel 2021, can return multiple matches if you use the “match mode” and “search mode” arguments, but it still doesn’t sum them directly. For summing, XLOOKUP is not a substitute for SUMIF. However, XLOOKUP can be used in a similar way to VLOOKUP inside SUMPRODUCT, and it has the advantage of not requiring a specific column order.
For example, to sum prices for a list of items using XLOOKUP:
=SUMPRODUCT(B2:B100 * XLOOKUP(A2:A100, D2:D10, E2:E10))
This works the same as the VLOOKUP version but is easier to read because the lookup array and return array are separate.
Frequently Asked Questions
Can I use VLOOKUP to sum all matching values?
No, VLOOKUP returns only the first match. To sum all matching values, use SUMIF or SUMIFS. For example, =SUMIF(A:A, "Apple", B:B) sums all B values where A equals “Apple”.
How do I sum a column based on a VLOOKUP result?
Use the VLOOKUP result as the criteria in SUMIF. For instance, if VLOOKUP returns a product name in cell D1, then =SUMIF(A2:A100, D1, B2:B100) sums all sales for that product.
Why does my VLOOKUP return #N/A when the value exists?
Common causes: the lookup value is text but the table has numbers (or vice versa), extra spaces, or the value is not in the first column of the table. Use TRIM to remove spaces, and ensure data types match. Also, use FALSE for exact match.
Is there a way to sum multiple VLOOKUP results without adding them manually?
Yes, use SUMPRODUCT with an array of lookup values. For example, =SUMPRODUCT(VLOOKUP({"Apple","Banana"}, A2:B10, 2, FALSE)) sums the returned values for both items. In Excel 365, this works as a dynamic array; in older versions, you may need to enter it as an array formula.
What is the difference between SUMIF and SUMIFS?
SUMIF sums a range based on one condition. SUMIFS sums a range based on multiple conditions, and its argument order is different: the sum range comes first. For example, =SUMIFS(sum_range, criteria_range1, criteria1, criteria_range2, criteria2).
Can I use VLOOKUP with SUM in Google Sheets?
Yes, the same functions exist in Google Sheets. SUMIF, SUMIFS, and SUMPRODUCT work similarly. VLOOKUP also works the same way. The main difference is that array formulas in Google Sheets are handled automatically, so you don’t need Ctrl+Shift+Enter for SUMPRODUCT with VLOOKUP.
Related
- By Means of an Update? Meaning & Real Usage
- Windows Ctrl Shortcuts: The Complete List
- Speed and Intersection Safety Cameras: How They Work
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Conditional Formatting Based on a FormulaYes. In Excel for Microsoft 365 on Windows, select the cells to format, then choose Home > Conditional…
- Excel Formula for Percentage Increase: Examples and TipsTo calculate percentage increase in Excel, subtract the old value from the new value, then divide by the…
- Excel SUBTOTAL Formula for Sum: Examples and TipsTo sum a range with Excel’s SUBTOTAL function, use =SUBTOTAL(9,A2:A20); it sums visible values and automatically excludes rows…
- COUNTIF Excel Blank? Count Empty Cells CorrectlyTo count blank cells in Excel, use =COUNTIF(A2:A20,""), replacing A2:A20 with your range. COUNTIF can also count cells…
- How to Filter by Month in Excel Using Dates or TextTo filter month-wise in Excel, select a cell in your data, choose Data > Filter, open the date…
- Power Query Find Text in a String: M Functions and ExamplesTo find whether a Power Query text value contains a word or phrase, use Text.Contains. In a Custom…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.