Spreadsheet Practice

How to remove a prefix from text in Excel

Formula (Excel and Google Sheets)

=IF(LEFT(A2,LEN($E$1))=$E$1,MID(A2,LEN($E$1)+1,LEN(A2)),A2)

Check for the prefix, then keep what follows it: =IF(LEFT(A2,LEN($E$1))=$E$1,MID(A2,LEN($E$1)+1,LEN(A2)),A2).

Result on the example
one result per row in B2, filled down to B6
Works in
Excel 2024 and Microsoft 365
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

LEFT takes as many characters as the prefix has and compares them with it (ignoring case). When they match, MID returns everything after the prefix; when they don't, as for "A2290", the value is returned as it is. Only a prefix at the very start is removed.

=IF(LEFT(A2,LEN($E$1))=$E$1,MID(A2,LEN($E$1)+1,LEN(A2)),A2)

Result"10442"

  1. A2"SKU-10442"

    The value in A2.

  2. $E$1"SKU-"

    The value in E1.

  3. LEN($E$1)4

    LEN: Number of characters.

    • text$E$1"SKU-"
  4. LEFT(A2,LEN($E$1))"SKU-"

    LEFT: Characters from the start of text.

    • textA2"SKU-10442"
    • num_charsLEN($E$1)4
  5. LEFT(A2,LEN($E$1))=$E$1TRUE

    The = operator tests whether the two sides are equal.

  6. LEN($E$1)4

    LEN: Number of characters.

    • text$E$1"SKU-"
  7. LEN($E$1)+15

    The + operator adds.

  8. LEN(A2)9

    LEN: Number of characters.

    • textA2"SKU-10442"
  9. MID(A2,LEN($E$1)+1,LEN(A2))"10442"

    MID: Characters from the middle of text.

    • textA2"SKU-10442"
    • start_numLEN($E$1)+15
    • num_charsLEN(A2)9
  10. IF(LEFT(A2,LEN($E$1))=$E$1,MID(A2,LEN($E$1)+1,LEN(A2)),A2)"10442"

    IF: Returns one value if a test is true, another if false.

    • logical_testLEFT(A2,LEN($E$1))=$E$1TRUE
    • value_if_trueMID(A2,LEN($E$1)+1,LEN(A2))"10442"
    • value_if_falseA2"SKU-10442"not used

In Google Sheets

The same formula works in Google Sheets: =IF(LEFT(A2,LEN($E$1))=$E$1,MID(A2,LEN($E$1)+1,LEN(A2)),A2). 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
=TEXTAFTER(A2,$E$1,,1,,A2)10442, 10457, A2290…Excel 365: the text after the prefix, ignoring case (the 1), or the whole value when the prefix isn't there. It would also cut at a match in the middle.
=SUBSTITUTE(A2,$E$1,"",1)10442, 10457, A2290…Different resultQuick, but case-sensitive and not limited to the start of the text. "sku-10520" keeps its lowercase prefix.

Common mistakes

  • SUBSTITUTE removes the text wherever it appears, not only at the start.
  • Hard-coding the length, as in MID(A2,5,…), breaks when the prefix changes. Use LEN of the prefix cell.

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 a prefix from text

In B2, remove the prefix in E1 from the start of the SKU, leaving SKUs without it unchanged, and fill down to B6.

Questions

How do I remove a suffix instead?

Check the end: =IF(RIGHT(A2,LEN($E$1))=$E$1,LEFT(A2,LEN(A2)-LEN($E$1)),A2).

How do I add the prefix back?

Join it: =$E$1&B2.

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.