Spreadsheet Practice

How to remove the last N characters from a cell in Excel

Formula (Excel and Google Sheets)

=LEFT(A2,LEN(A2)-$E$1)

Keep everything except the last N characters: =LEFT(A2,LEN(A2)-3).

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

See it work

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

How it works

LEN(A2)-$E$1 is the length without the last N characters, and LEFT keeps that many from the start. Here it strips the "-01" revision suffix whatever the length of the invoice number.

=LEFT(A2,LEN(A2)-$E$1)

Result"INV1042"

  1. A2"INV1042-01"

    The value in A2.

  2. LEN(A2)10

    LEN: Number of characters.

    • textA2"INV1042-01"
  3. $E$13

    The value in E1.

  4. LEN(A2)-$E$17

    The - operator subtracts.

  5. LEFT(A2,LEN(A2)-$E$1)"INV1042"

    LEFT: Characters from the start of text.

    • textA2"INV1042-01"
    • num_charsLEN(A2)-$E$17

In Google Sheets

The same formula works in Google Sheets: =LEFT(A2,LEN(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
=REPLACE(A2,LEN(A2)-$E$1+1,$E$1,"")INV1042, INV1043, INV987…Replaces the last N characters with nothing.

Common mistakes

  • Trailing spaces count as characters. TRIM first if the data was imported: =LEFT(TRIM(A2),LEN(TRIM(A2))-3).
  • If N is larger than the text, LEFT gets a negative length and returns #VALUE!.
  • When the suffix length varies, cut at the delimiter instead: =TEXTBEFORE(A2,"-",-1).

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.

Remove the last N characters from a cell

In B2, remove the last N characters from the invoice, where N is in E1, and fill down to B6.

Questions

How do I remove only the last character?

Use =LEFT(A2,LEN(A2)-1).

How do I remove the last character only if it is a comma?

Test it first: =IF(RIGHT(A2)=",",LEFT(A2,LEN(A2)-1),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.