Spreadsheet Practice

How to find the longest text in a column in Excel

Excel formula

=XLOOKUP(MAX(LEN(A2:A7)),LEN(A2:A7),A2:A7)

Find the largest length and return the text that has it: =XLOOKUP(MAX(LEN(A2:A7)),LEN(A2:A7),A2:A7).

Result on the example
Noise-cancelling wireless headset in C2
Works in
Excel 2021, 2024 and Microsoft 365
Google Sheets
Different formula, see below

See it work

The formula is already in C2. Change any input and the result updates, or edit the formula to experiment.

How it works

LEN(A2:A7) gives the length of every title at once, and MAX picks the largest, 33. XLOOKUP then finds that length in the same list and returns the title on that row.

=XLOOKUP(MAX(LEN(A2:A7)),LEN(A2:A7),A2:A7)

Result"Noise-cancelling wireless headset"

  1. A2:A76 rows × 1 col: "Desk lamp", "Ergonomic office chair", "Adjustable standing desk, walnut", "USB-C dock", …

    A range: 6 cells in one column.

  2. LEN(A2:A7){6 rows × 1 col} 9, 22, 32, 10, …

    LEN: Number of characters.

    • textA2:A76 rows × 1 col: "Desk lamp", "Ergonomic office chair", "Adjustable standing desk, walnut", "USB-C dock", …
  3. MAX(LEN(A2:A7))33

    MAX: Largest number.

    • number1LEN(A2:A7){6 rows × 1 col} 9, 22, 32, 10, …
  4. LEN(A2:A7){6 rows × 1 col} 9, 22, 32, 10, …

    LEN: Number of characters.

    • textA2:A76 rows × 1 col: "Desk lamp", "Ergonomic office chair", "Adjustable standing desk, walnut", "USB-C dock", …
  5. XLOOKUP(MAX(LEN(A2:A7)),LEN(A2:A7),A2:A7)"Noise-cancelling wireless headset"

    XLOOKUP: Searches one range and returns the matching item from another.

    • lookup_valueMAX(LEN(A2:A7))33
    • lookup_arrayLEN(A2:A7){6 rows × 1 col} 9, 22, 32, 10, …
    • return_arrayA2:A76 rows × 1 col: "Desk lamp", "Ergonomic office chair", "Adjustable standing desk, walnut", "USB-C dock", …

In Google Sheets

Google Sheets needs a different formula: =ARRAYFORMULA(INDEX(A2:A7,MATCH(MAX(LEN(A2:A7)),LEN(A2:A7),0))). On the same data it gives the same result. Here it is running in Google Sheets mode.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=INDEX(A2:A7,MATCH(MAX(LEN(A2:A7)),LEN(A2:A7),0))Noise-cancelling wireless headsetWithout XLOOKUP. In Excel 2019 and earlier, confirm with Ctrl+Shift+Enter.
=MAX(LEN(A2:A7))33Different resultJust the length of the longest text. Returns 33, the number of characters.

Common mistakes

  • Ties return the first title with that length.
  • Trailing spaces count toward the length. Use LEN(TRIM(A2:A7)) in both places for imported data.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Find the longest text in a column

In C2, return the longest product title in A2:A7.

Questions

How do I find the shortest text?

Use MIN: =XLOOKUP(MIN(LEN(A2:A7)),LEN(A2:A7),A2:A7). Blank cells count as length 0, so exclude them if the column has gaps.

How do I list every title over a length limit?

Filter by length: =FILTER(A2:A7,LEN(A2:A7)>30).

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.