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 toB6 - 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"
A2"SKU-10442"The value in A2.
$E$1"SKU-"The value in E1.
LEN($E$1)4LEN: Number of characters.- text
$E$1"SKU-"
- text
LEFT(A2,LEN($E$1))"SKU-"LEFT: Characters from the start of text.- text
A2"SKU-10442" - num_chars
LEN($E$1)4
- text
LEFT(A2,LEN($E$1))=$E$1TRUEThe = operator tests whether the two sides are equal.
LEN($E$1)4LEN: Number of characters.- text
$E$1"SKU-"
- text
LEN($E$1)+15The + operator adds.
LEN(A2)9LEN: Number of characters.- text
A2"SKU-10442"
- text
MID(A2,LEN($E$1)+1,LEN(A2))"10442"MID: Characters from the middle of text.- text
A2"SKU-10442" - start_num
LEN($E$1)+15 - num_chars
LEN(A2)9
- text
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_test
LEFT(A2,LEN($E$1))=$E$1TRUE - value_if_true
MID(A2,LEN($E$1)+1,LEN(A2))"10442" - value_if_false
A2"SKU-10442"not used
- logical_test
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.
| Formula | Result | When 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 result | Quick, 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
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.