Excel Formula to Extract the Longest Matching Brand from Product Text
Question details
Find a brand from a predefined list within each product description and return the longest matching brand in a separate column.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A brand list contains overlapping names, such as EASI and EASIGAS, and product descriptions need to be labeled with the best match.
- Observed behavior
- A formula that returns the first matching brand may select a shorter name instead of the longer brand present in the description.
Place the brand list in A2:A7 and the first product description in D2, or adjust the cell references in the formula to match your sheet. The recommended formula uses Microsoft 365 functions including LET, FILTER, and SORTBY.
Use a Microsoft 365 formula to return the longest matching brand
Search every nonblank brand in the description and return the longest match, regardless of its position in the list.
SEARCH is case-insensitive and looks for each brand as a substring. The formula favors EASIGAS over EASI, but it does not enforce whole-word boundaries.
Select the output cell next to the description, such as E2, and enter: =LET(brands,$A$2:$A$7,txt,D2,hit,(brands<>"")*ISNUMBER(SEARCH(brands,txt)),IF(SUM(hit)=0,"No Match",LET(m,FILTER(brands,hit),INDEX(SORTBY(m,LEN(m),-1),1))))
Press Enter, then drag the fill handle from E2 down the output column. The brand range stays fixed while the description reference changes for each row.
Compare the returned brand with the text in column D. If no nonblank brand is found, the cell displays No Match.

Find the Longest Matching Brand in WPS Spreadsheets
Use helper columns in WPS Spreadsheets to score each brand by its matching length, then return the longest match for each product description.
- 1. Set up the sheet: Open the workbook in WPS Spreadsheets. Put product descriptions in D2 downward and enter the six brand names as headers in E1:J1.
- 2. Score each brand: In E2, enter =IF(E$1="",0,IF(ISNUMBER(SEARCH(E$1,$D2)),LEN(E$1),0)), then drag the fill handle across to J2 and down for the remaining descriptions.
- 3. Return the longest match: In K2, enter =IF(MAX(E2:J2)=0,"No Match",INDEX(E$1:J$1,1,MATCH(MAX(E2:J2),E2:J2,0))) and press Enter.
- 4. Fill the results down: Drag the fill handle from K2 down alongside the descriptions. Adjust the E:J ranges if you have a different number of brand headers.

Frequently Asked Questions
Why does the formula return EASIGAS instead of EASI?
Both names appear in EASIGAS, but SORTBY orders the matching brands by length in descending order, so the longer name is returned first.
Is the brand search case-sensitive?
No. SEARCH ignores case, so a brand listed as EASIGAS can match text written as Easigas.
Does the formula match whole words only?
No. SEARCH finds substrings, so a brand may match inside another word. Whole-word matching requires additional rules for the separators used in your product text.
What happens when two matching brands have the same length?
The formula returns the first one in the sorted results. Add a separate tie-breaking rule if equal-length matches need a specific priority.




