How to Sum If Ends With in Excel

Learn multiple Excel methods to sum if ends with with step-by-step examples and practical applications.

excelformulaspreadsheettutorial
12 min read • Last updated: 7/2/2025

How to Sum If Ends With in Excel

Why This Task Matters in Excel

In day-to-day spreadsheet work you rarely receive data that is perfectly structured. In many industries, identifiers, codes, and text labels end with a meaningful suffix: product numbers that finish with a region code, invoice IDs that end in a year marker, or employee IDs whose last character indicates job level. When analysts need to aggregate numeric values—sales, quantities, hours—based on those suffixes, the ability to “sum if ends with” becomes indispensable.

Consider a retail company that sells the same product line in several countries. The SKU “PRD‐A-US” might represent the American version, while “PRD-A-UK” represents the British version. The finance department often needs to total revenue for all SKUs that end in “-US” to prepare domestic sales reports. Without an efficient formula, analysts would resort to manual filtering or pivot tables, adding unnecessary time and risk of error.

In supply-chain management, purchase order numbers may end with supplier abbreviations, such as “PO1234-LG” for LG Electronics. Summing the cost of orders that end with a given supplier code allows quick reconciliation of supplier accounts. Meanwhile, in education, course codes such as “MATH101F23” end with a term indicator (“F23” for Fall 2023). Summing student enrollments that end in “F23” instantly answers how many seats were filled in the fall semester.

These real-world scenarios share three common needs: pattern matching, conditional aggregation, and repeatability. Excel excels (pun intended) here because it offers wildcard-aware conditional functions like SUMIF and SUMIFS, dynamic array tools such as FILTER, and powerful catch-all methods like SUMPRODUCT. Mastering “sum if ends with” means mastering a versatile skill that saves hours of ad-hoc filtering, supports automated dashboards, and underpins more advanced topics like dynamic reporting and VBA automation. Neglecting the skill often leads to incorrect financial statements, delayed deliverables, and embarrassing rework when manual filters miss just one record. The technique also dovetails neatly with data validation, structured references in Tables, and Power Query; so sharpening it improves your entire analytical workflow.

Best Excel Approach

The go-to method for summing values where the lookup text ends with a specific suffix is the wildcard-enabled SUMIF (or SUMIFS for multiple conditions). It is simple, efficient, and compatible with every Excel version released since 2003.

Syntax refresher:

=SUMIF(range, criteria, [sum_range])
  • range – the cells you want to test
  • criteria – the pattern to match (wildcards * and ?)
  • [sum_range] – the cells whose numbers you actually add (optional if the range itself is numeric)

For “ends with,” the pattern uses an asterisk at the beginning: "*US" finds every cell that finishes with “US” no matter what precedes it. Place the pattern inside double quotes, concatenate when the suffix lives in another cell, and escape literal question marks or asterisks with a tilde (~) if they appear in your data.

When should you pick SUMIF versus alternatives?

  • Choose SUMIF/SUMIFS when your suffix criterion is the only (or primary) filter, you want high speed, and backward compatibility matters.
  • Switch to SUMPRODUCT when you need array-level flexibility such as case-sensitive checks or pattern lists.
  • Use SUM(Filter()) with the FILTER function if you are in Microsoft 365 and prefer a spill-based, decoupled approach or need the filtered records for other formulas.

Recommended single-condition formula:

=SUMIF($B$2:$B$100,"*"&$E$1,$C$2:$C$100)

Alternative with multiple conditions (for example, suffix equals “US” and year equals 2023):

=SUMIFS($C$2:$C$100,$B$2:$B$100,"*"&$E$1,$D$2:$D$100,$E$2)

Parameters and Inputs

  • Text range (criteria range) – Usually a column of product codes or IDs. Must be formatted as plain text or mixed text/numbers; leading zeros preserved.
  • Criteria suffix – The text you want to match at the end. Accepts direct typing "US" or a cell reference like [E1].
  • Wildcard placement – Prepend an asterisk to the suffix ("*US"). Do not add it after the suffix; that would match anything starting with the suffix instead.
  • Sum range – Numeric data (sales, quantities, costs). Ensure no non-numeric entries like “N/A”; otherwise SUMIF treats text as zero, which can mask errors.
  • Optional additional ranges (SUMIFS only) – Each extra condition range must be exactly the same size (same rows) as the sum range.
  • Data preparation – Remove trailing spaces with TRIM, ensure consistent text case if you rely on case-sensitive alternatives, and convert mixed data in Tables to the correct column type.
  • Edge cases – Empty cells in the criteria range are ignored; empty cells in the sum range are treated as zero. If you need to treat blanks in the sum range as errors, wrap the SUMIF inside IFERROR checks.

Step-by-Step Examples

Example 1: Basic Scenario

Suppose you have the following dataset in a standard sheet:

ABC
DateSKUSales
01-Jan-23PRD-A-US1430
02-Jan-23PRD-B-UK790
03-Jan-23PRD-A-US2200
04-Jan-23PRD-C-US560
05-Jan-23PRD-B-UK1010

Goal: Total sales for any SKU ending in “-US”.

Step 1 – Enter the suffix you care about in cell [E1] for flexibility: -US.
Step 2 – Place the following formula in [E2]:

=SUMIF(B2:B6,"*"&E1,C2:C6)

How it works:

  1. The criteria pattern becomes "*-US" after concatenation.
  2. Excel scans [B2:B6] row by row to see if the text fits the pattern (case-insensitive).
  3. For every match, it grabs the corresponding numeric value from [C2:C6].
  4. It then adds the matched numbers: 1430 + 2200 + 560 = 4190.

Why this logic is bullet-proof: The asterisk wildcard means “any number of characters,” so it covers one-character prefixes such as “A” or longer prefixes like “PRD-XYZ”. Placing the wildcard at the start guarantees we only match the end pattern.

Variations:

  • If your suffix lives immediately after a dash but before a possible version code (for example “-US-V2”), you can nest SUBSTITUTE to strip the trailing part first.
  • For case sensitivity, wrap the formula in SUMPRODUCT(–(EXACT(...))) (see Example 3).

Troubleshooting: If you get zero, check for hidden spaces: PRD-A-US will not match. Use TRIM or LEN to diagnose.

Example 2: Real-World Application

Scenario: A multi-national e-commerce company wants quarterly profit by fulfillment center. Their order IDs end with the fulfillment code: “...-WH1”, “...-WH2”, “...-AIR1”. The finance team needs total profit for warehouse WH1 for Q1 only.

Sample table (in an Excel Table named Orders):

OrderIDDateProfitRegion
OR2023Q1-0001-WH103-Jan-2335.60NA
OR2023Q1-0023-WH207-Jan-2318.20EU
OR2023Q1-0155-WH105-Mar-2342.15NA
OR2023Q2-0001-WH110-Apr-2340.00NA

Requirements:

  • Suffix ends with “-WH1”
  • Date falls in Q1 of 2023

Because we have two criteria, use SUMIFS:

=SUMIFS(Orders[Profit],
        Orders[OrderID],"*"&$H$1,
        Orders[Date],">="&DATE(2023,1,1),
        Orders[Date],"<="&DATE(2023,3,31))

Explanation:

  • Orders[Profit] is the sum range.
  • Orders[OrderID] criteria checks for any text ending “-WH1” (H1 contains -WH1).
  • The date criteria create a between filter to capture Q1.
  • The formula sums 35.60 + 42.15 = 77.75.

Business insights: The analyst can paste this formula across four quarters by adjusting the DATE boundaries or by referencing a dynamic calendar table. By naming the Table “Orders,” the range automatically expands—key for live dashboards.

Integration: You may feed the result into a PowerPoint linked cell, or use it as a value field in a cube formula for dynamic narratives.

Performance: Even with 100k rows, SUMIFS is optimized with native C code. Ensure your criteria columns are contiguous to help CPU caching when possible.

Example 3: Advanced Technique

Edge case: The suffix is case-sensitive. Consider a biotech lab where sample IDs end with reagents “-aB”, “-Ab”, and “-ab”. Each suffix has a different meaning, and you must sum readings only where the suffix exactly matches “-aB” (case matters). SUMIF cannot do this, so switch to SUMPRODUCT combined with EXACT and RIGHT functions.

Data sample:

AB
SampleIDOD600
TST001-aB0.450
TST002-Ab0.380
TST003-aB0.500
TST004-ab0.200

Formula in [D2] with suffix in [D1] (“-aB”):

=SUMPRODUCT(--(EXACT(RIGHT(A2:A5,LEN($D$1)),$D$1))*B2:B5)

Walkthrough:

  1. LEN($D$1) returns 3, the length of “-aB”.
  2. RIGHT(A2:A5,3) extracts the last three characters of each ID.
  3. EXACT compares each extracted suffix to “-aB” in a case-sensitive manner, returning TRUE or FALSE.
  4. The double unary (--) converts TRUE/FALSE to 1/0.
  5. SUMPRODUCT multiplies each 1/0 flag by the numeric value in [B2:B5] and adds the products.

Advanced tips:

  • If IDs vary in length but the suffix length is always three, this formula holds.
  • For variable suffix length, replace LEN($D$1) with a dynamic computed length.
  • SUMPRODUCT is slower than SUMIFS on very large datasets; cache intermediate columns if needed or offload to Power Query.

Error handling: Wrap the formula in IFERROR if OD600 may contain #N/A due to missing data:

=IFERROR(SUMPRODUCT(--(EXACT(RIGHT(A2:A500,LEN($D$1)),$D$1))*B2:B500),0)

Tips and Best Practices

  1. Store suffix criteria in a separate cell (or named range) rather than hard-coding it; this allows quick re-use and scenario testing.
  2. Convert raw data into Excel Tables so ranges auto-resize and formulas become more readable (e.g., Orders[OrderID]).
  3. Combine SUMIFS with dynamic date boundaries using EOMONTH or a dedicated calendar sheet for fully automated period reporting.
  4. For extremely large reports, pre-filter the dataset with a slicer-connected Table before applying SUMIF to minimize processed rows.
  5. Document your wildcard logic in a comment or cell note—future maintainers may not immediately realize "*US" means ends with US.
  6. When suffixes could contain wildcards themselves (literal asterisk), prefix them with a tilde in criteria: "*~*"&suffix.

Common Mistakes to Avoid

  1. Forgetting the leading asterisk. Writing "US" instead of "*US" switches from “ends with” to “exact match,” yielding incomplete totals.
  2. Mixing range sizes in SUMIFS. All criteria ranges must align exactly with the sum range, otherwise Excel returns a #VALUE! error.
  3. Overlooking trailing spaces. Hidden blanks after text cause unexpected non-matches. Use CLEAN/TRIM or Data > Text to Columns to fix.
  4. Assuming case sensitivity with SUMIF. Standard SUMIF and SUMIFS are not case-sensitive; if the distinction matters, pivot to SUMPRODUCT or a helper column using EXACT.
  5. Relying on manual filtering instead of formulas. Filters don’t automatically update when new data arrives, leading to stale reports. Adopt formula-based logic for robustness.

Alternative Methods

Below is a comparison of other ways to achieve “sum if ends with”:

MethodProsConsBest for
SUMIF/SUMIFS wildcardFast, simple, backward compatibleNot case-sensitiveMost everyday tasks
SUMPRODUCT + RIGHTCase sensitive, flexibleSlower on big data, longer formulaScientific or precise matching
FILTER + SUMReturns spill range for inspectionMicrosoft 365 onlyInteractive dashboards
Helper column + SUMIFImproves speed with multiple suffixExtra column clutterVery large datasets
Pivot TableNo formulas, drag-and-drop totalsManual refresh, limited automationAd-hoc analysis

When migrating, test results side-by-side. For example, replace a SUMPRODUCT with SUMIF after confirming case doesn’t matter; this can cut calculation time significantly.

FAQ

When should I use this approach?

Use it whenever numeric aggregation depends on a textual suffix—sales by country code, costs by vendor abbreviation, or metrics by time period embedded at the end of an ID. It is ideal for repeatable monthly or weekly reports where new rows are constantly appended.

Can this work across multiple sheets?

Yes. Qualify the ranges with sheet names inside the formula:

=SUMIF('Jan Data'!B:B,"*"&$E$1,'Jan Data'!C:C)

For multiple sheets, SUM across 12 months by wrapping each SUMIF in SUM and adding them, or build a 3D SUMIF via INDIRECT inside SUMPRODUCT—but be mindful of performance.

What are the limitations?

SUMIF and SUMIFS are not case-sensitive, only allow one wildcard criterion per range, and cannot easily search a list of suffixes in a single call. They also ignore pattern positions other than starts with, ends with, or contains (depending on wildcard placement). Microsoft 365 users can circumvent some constraints with dynamic arrays.

How do I handle errors?

If your numeric column might contain errors like #DIV/0!, wrap it in IFERROR within SUMPRODUCT, or create a sanitized helper column. In Tables, use [[@Sales]] with IFERROR inside the column definition so the main SUMIF always sees clean numbers.

Does this work in older Excel versions?

Yes—SUMIF with wildcards functions all the way back to Excel 2003. SUMPRODUCT also works, but FILTER requires Microsoft 365 or Excel 2021.

What about performance with large datasets?

SUMIF/SUMIFS are highly optimized. Ensure calculation mode is set to Automatic except for very large models. Use whole-column references sparingly (e.g., B:B) because they force Excel to scan one million rows; range-bound references such as B2:B100000 are faster. For 500k+ rows, consider Power Pivot or Power Query for ETL and DAX measures.

Conclusion

Being able to “sum if ends with” is a deceptively simple skill that unlocks sophisticated pattern-based reporting. Whether you are reconciling supplier spend, preparing regional sales dashboards, or calculating lab results, these techniques turn messy alphanumeric strings into actionable numbers. You have learned the quick wildcard-based SUMIF, the multi-condition SUMIFS, and advanced, case-sensitive SUMPRODUCT alternatives. Master them, and you will streamline recurring tasks, reduce manual errors, and lay the groundwork for deeper analytics such as Power Pivot or VBA automation. Keep practicing by adapting the examples to your own datasets, and you will soon handle any suffix-driven scenario with confidence.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve.