Spreadsheet Practice

How to extract the first N characters from a cell in Excel

Formula (Excel and Google Sheets)

=LEFT(A2,$E$1)

Use =LEFT(A2,3) to return the first 3 characters. Put the number in a cell, as in =LEFT(A2,$E$1), to change it easily.

Result on the example
one result per row in B2, filled down to B7
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in B2, filled down to B7. Change any input and the result updates, or edit the formula to experiment.

How it works

LEFT returns a set number of characters from the start of the text. When every code has the same structure, like a three-letter category, that is all you need. If the length varies, split at a delimiter instead with TEXTBEFORE.

=LEFT(A2,$E$1)

Result"CHR"

  1. A2"CHR-0142-BLK"

    The value in A2.

  2. $E$13

    The value in E1.

  3. LEFT(A2,$E$1)"CHR"

    LEFT: Characters from the start of text.

    • textA2"CHR-0142-BLK"
    • num_chars$E$13

In Google Sheets

The same formula works in Google Sheets: =LEFT(A2,$E$1). We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=MID(A2,1,$E$1)CHR, DSK, LMP…MID starting at position 1 does the same; it's the form to use when the start position can change.

Common mistakes

  • LEFT always returns text, even from a number: =LEFT(12345,2) is the text "12". Wrap it in VALUE to get a number.
  • On a date, LEFT works on the serial number, not on what you see. Use TEXT first, like LEFT(TEXT(A2,"yyyy-mm-dd"),4).
  • Leaving out the second argument returns just 1 character.

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.

Extract the first N characters from a cell

In B2, return the first N characters of the SKU, where N is in E1, and fill down to B7.

Questions

How do I get everything except the first N characters?

Use =RIGHT(A2,LEN(A2)-$E$1) or =MID(A2,$E$1+1,LEN(A2)).

How do I get the text up to the first dash when the length varies?

Use =TEXTBEFORE(A2,"-").

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.