Smart Statistics · Excel tutorial · 3 December 2026
Excel SUMIFS Wildcards: Match the Job Code You Actually Entered
A job code can contain an asterisk without meaning “anything goes”. Build an Excel total that treats the code as business data, rather than an unintended search pattern.
Illustrative example · all dashboard figures
Selected job: A*1
Hours returned by the two criteria
Review status: literal result reconciles to the selected job row.
Evidence trail: original job code → escaped criterion → matching-row count → hours total → source-row review.
Illustrative example · five fictional time entries. The 26-hour difference is a matching error, not a real saving.
The formula works, but answers a different question
A project administrator totals hours against a customer’s job reference. The reference is A*1, with an actual asterisk in the code. A straightforward SUMIFS formula returns hours from several other jobs as well.
Excel criteria interpret * as a sequence of characters and ? as one character. A cell reference does not switch that interpretation off. Microsoft documents these wildcard rules for SUMIFS. [1]
This tutorial creates a literal-text criterion before summing. It is useful when punctuation is part of an identifier and the requirement is to total that identifier’s records. If the business deliberately wants a pattern search, retain a separately labelled pattern-search input.
Create a small fixture you can explain
Use a blank worksheet in Excel for Microsoft 365 or a supported version with SUMIFS and SUBSTITUTE. The functions are also documented for Excel 2016 and later. No macros or dynamic-array functions are needed.
- Type JobCode in A1 and Hours in B1. Enter the five rows below in A2:B6. Keep Hours numeric.
- Select A1:B6, choose Insert → Table and confirm that the table has headers. Name it tblJobs in the table-name box.
- In H1 type Selected job. Format H2 as Text, then enter A*1. This is the original code, without escape characters.
| JobCode | Hours |
|---|---|
| A*1 | 2 |
| A01 | 3 |
| AB1 | 5 |
| A?1 | 7 |
| A~1 | 11 |
In H4, enter this deliberately unescaped comparison formula:
=SUMIFS(tblJobs[Hours],tblJobs[JobCode],H2)
It returns 28. Every code in this fixture starts with A and ends with 1, so the asterisk criterion matches all five. Formatting H2 as Text preserves the entry but does not make SUMIFS treat its wildcard characters literally.
Build the criterion in a separate cell
Type Literal criterion in I1 and enter this formula in I2:
=IF(H2="","","="&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(H2,"~","~~"),"*","~*"),"?","~?"))
For A*1, I2 displays =A~*1. That displayed text is a criterion produced by a formula, not a second formula to execute.
The three substitutions run from the inside out. First double existing tildes. Then prefix each asterisk and question mark with a tilde. Microsoft documents the tilde escape convention and that SUBSTITUTE replaces every occurrence when its optional occurrence argument is omitted. [2] [3]
Preserve the source code
Keep A*1 in the source and input. The escaped text belongs only in the formula’s criteria argument. Do not rewrite the job register with tildes.
Escape tildes first
If you escape asterisks first and then double every tilde, you also alter the escape characters you just inserted. The order is part of the method.
The leading equals sign makes the intended comparison explicit. It does not disable wildcards by itself: =A*1 remains a pattern, whereas =A~*1 requests a literal asterisk. The blank-input guard stops an empty selection becoming a blank-code search.
Return the total and its supporting count
Type Literal hours in J1 and put this formula in J2:
=IF(H2="","",SUMIFS(tblJobs[Hours],tblJobs[JobCode],I2))
Type Matching rows in K1 and put this formula in K2:
=IF(H2="","",COUNTIF(tblJobs[JobCode],I2))
With A*1 selected, J2 returns 2 and K2 returns 1. The count makes a zero-hour result easier to interpret: zero matching rows means no matched code, while a positive count with zero hours needs inspection of the matched entries.
Several rows for the same job can be legitimate time entries. A count above one does not automatically mean a duplicate. Check the business record identifier when investigating repeated uploads.
For a compact workbook, the total can be written without the helper cell:
=IF(H2="","",SUMIFS(
tblJobs[Hours],
tblJobs[JobCode],
"="&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(H2,"~","~~"),"*","~*"),"?","~?")
))
Keep the helper-cell version during testing because it exposes the actual criterion. These examples use English function names and commas; installations with different regional settings may require different separators.
Test characters, not just the first successful total
| H2 input | I2 criterion | J2 hours | K2 rows |
|---|---|---|---|
| A*1 | =A~*1 | 2 | 1 |
| A?1 | =A~?1 | 7 | 1 |
| A~1 | =A~~1 | 11 | 1 |
| A01 | =A01 | 3 | 1 |
| Z99 | =Z99 | 0 | 0 |
| Blank | Blank | Blank | Blank |
Then add A~*1 with 13 hours as a sixth table row. Select that code in H2. The criterion must be =A~~~*1, with three consecutive tildes, and the result must be 13 hours from one row. This tests a real tilde immediately followed by a real asterisk.
As a separate test, add another A*1 row with 4 hours. Selecting A*1 should now return 6 hours from two rows. The formula must include both valid entries without adding neighbouring codes. Remove test additions before checking the original expected table again.
Finally, test case explicitly. With the original fixture, selecting a*1 also returns 2 hours. If your organisation treats A*1 and a*1 as different jobs, this SUMIFS method is unsuitable; use an approved case-sensitive comparison instead.
Put the fix where the workbook is maintained
The job-data owner confirms whether punctuation and letter case carry meaning. The workbook owner maintains the criterion formula and regression fixture. The operational reviewer checks matching records before using the total in job costing or workload discussions.
Keep raw codes intact. Do not remove punctuation or trim spaces without an agreed rule: two different identifiers can otherwise collapse into one. Keep hours numeric and flag invalid entries; escaping a criterion does not fix text amounts, missing records or duplicate ingestion.
Introduce the corrected result beside the existing calculation for a short review. Investigate changed totals against source rows and record the approved explanation. Protect formula cells from routine editing while keeping the input and evidence visible.
Measure the number of incorrect job matches found, time spent resolving unexplained totals and completion of the regression tests after workbook changes. Treat any improvement as a measured outcome. The illustrative 26-hour difference is a correction to attribution, not labour time released.
Is the matching rule ready to use?
The first two controls are essential. Tick only checks you can demonstrate.
Answers are not submitted or saved.
Frequently asked questions
Does formatting the input as Text disable wildcards?
No. Text formatting preserves the entry, but SUMIFS still interprets wildcard characters in its criteria. Escape the criterion separately.
Why are existing tildes replaced first?
Later substitutions introduce new tilde escape characters. Replacing tildes afterwards would also alter those new escapes.
Is this matching case-sensitive?
No. SUMIFS does not distinguish uppercase and lowercase codes. Use a separately tested case-sensitive method when case is part of the identifier.
Should the source job code contain the extra tildes?
No. Preserve the source code. Build the escaped text only for the criteria argument used by the formula.
Technical references
Microsoft documentation checked on 3 December 2026. All job records and outcomes are illustrative.
- Microsoft Support: SUMIFS — criteria and wildcard behaviour.
- Microsoft Support: wildcard characters — literal characters and tilde escapes.
- Microsoft Support: SUBSTITUTE — replacing occurrences of text.