XLOOKUP with wildcards
The orders only say Riverside, but the list has the full name, Riverside Limited. An exact lookup finds nothing.
keyboard Typing formulas is easiest on a computer with a keyboard.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Company | Account | Customer | Account | |||
| 2 | Northgate Trading Co | AC-1324 | Riverside | ||||
| 3 | Copperfield Limited | AC-1876 | Greenleaf | ||||
| 4 | Brightway Trading Co | AC-1015 | Kestrel | ||||
| 5 | Riverside Limited | AC-2368 | Bluepeak | ||||
| 6 | Maple Limited | AC-2656 | Northgate | ||||
| 7 | Greenleaf Trading Co | AC-1375 | |||||
| 8 | Oakfield Ltd | AC-3430 | |||||
| 9 | Westbrook Trading Co | AC-2827 | |||||
| 10 | Kestrel Logistics | AC-2431 | |||||
| 11 | Bluepeak Foods Ltd | AC-3667 | |||||
| 12 | |||||||
| 13 | |||||||
| 14 | |||||||
| 15 |
How XLOOKUP works
What are wildcards?
Characters that stand for other characters when matching text:
*stands for any number of characters, even none. "Harbour*" matches Harbour Ltd and Harbour Foods.?stands for exactly one character. "Gr?y" matches Grey and Gray.~before * or ? means a real asterisk or question mark.
How do you use them in
XLOOKUP?Switch them on with 2 as the fifth part, match_mode. Without it,
XLOOKUPlooks for a real asterisk:=XLOOKUP(E2&"*",$A$2:$A$11, $B$2:$B$11, , 2) E2&"*"means "starts with what's inE2"."*"&E2&"*"means "contains it anywhere".Do other functions use them?
Yes, and there they are always on:
VLOOKUPandMATCHwith an exact match,COUNTIF,SUMIFand the otherIFSfunctions, andSEARCH.=COUNTIF(A2:A11,"*Ltd")counts the names ending in Ltd.What's the catch?
A wildcard returns the first match. If two names start with "Harbour", you get whichever comes first, so make the pattern specific enough.
Know someone fighting with a spreadsheet? Send them this page.