Use =LEN(A2) to measure text, =LEFT(A2,3) for the start, =RIGHT(A2,4) for the end and =MID(A2,5,3) for the middle. Choose by where the piece sits. When its length varies, find a delimiter with FIND, and let LEN work out how much text is left. All four are shown below on one column of asset tags.
Functions
LEN, LEFT, RIGHT and MID in Excel: Which to Use
Try this now
| A | B | C | D | |
|---|---|---|---|---|
| 1 | ||||
| 2 | Some Text | |||
| 3 | ||||
| 4 | ||||
| 5 |
Ready to practice?
Apply what you just learned with interactive exercises.
The point of this page is the decision, not four separate tutorials. Each function has its own guide, linked where it matters, and this page shows how they work together on messy, real-looking codes.
TL;DR
- LEN measures. LEFT takes from the start. RIGHT takes from the end. MID takes from the middle.
- Ask one question first: where does the piece sit, and is its position fixed? Fixed start, use LEFT. Fixed end, use RIGHT. Fixed middle, use MID.
- When prefixes differ in length, anchor from the end instead. =RIGHT(A2,4) works whether the tag starts with LAP or PHONE.
- To remove characters from the right, subtract: =LEFT(A2,LEN(A2)-5) drops the last five characters.
- Clean first. A single trailing space turns =RIGHT(A7,4) into "099 " instead of "0099". Use TRIM.
- All four functions return text. Wrap the result in VALUE before you do math on it.
Table of Contents
- Sample data used on this page
- The four functions at a glance
- Which function for which job
- Excel RIGHT for the end of the text
- Take a piece from the middle
- Remove characters from the right in Excel
- Anchor from the end when prefixes vary
- Let FIND and LEN do the counting
- Nest the functions
- Clean the tag before you cut it
- Alternatives to the four functions
- Excel versions
- Errors and their fixes
- What learners get wrong
- Worked scenario: audit a fixed-asset register
- Practice the four functions
- FAQ
- Sources
Sample data used on this page
A facilities team keeps its equipment in one column of asset tags. The pattern is type, site, purchase year, serial number, separated by dashes. The type is a different length on different rows (LAP, DOCK, PHONE), which is what makes the column awkward. Row 1 holds the header. The tag in A7 ends with a space, a common leftover from copy and paste.
| Row | A (Asset tag) |
| 2 | LAP-CPT-2024-0183 |
| 3 | MON-JHB-2023-0045 |
| 4 | DOCK-CPT-2025-0310 |
| 5 | PHONE-DBN-2022-0007 |
| 6 | LAP-JHB-2025-0422 |
| 7 | TAB-DBN-2024-0099 (ends with a space) |
The four functions at a glance
| Function | Syntax | Returns | Example on A2 |
| LEN | =LEN(text) | A number: how many characters | =LEN(A2) gives 17 |
| LEFT | =LEFT(text, [num_chars]) | The first characters | =LEFT(A2,3) gives LAP |
| RIGHT | =RIGHT(text, [num_chars]) | The last characters | =RIGHT(A2,4) gives 0183 |
| MID | =MID(text, start_num, num_chars) | Characters from any position | =MID(A2,5,3) gives CPT |
For deeper coverage of each, see the guides on LEN, LEFT and MID.
Which function for which job
| What you want | Where it sits | Use | Formula on this sheet |
| Is the tag the right length? | Whole text | LEN | =LEN(A2)=17 |
| Item type | Start, length varies | LEFT with FIND | =LEFT(A2,FIND("-",A2)-1) |
| Serial number | End, 4 characters | RIGHT | =RIGHT(A2,4) |
| Purchase year | 9th from the end, 4 long | MID with LEN, or LEFT of RIGHT | =MID(A2,LEN(A2)-8,4) |
| Site code | After the first dash | MID with FIND | =MID(A2,FIND("-",A2)+1,3) |
| Tag without its serial | Everything but the last 5 | LEFT with LEN | =LEFT(A2,LEN(A2)-5) |
| Tag without its type | Everything after the first dash | RIGHT with LEN and FIND | =RIGHT(A2,LEN(A2)-FIND("-",A2)) |
Excel RIGHT for the end of the text
=RIGHT(A2,4) returns "0183", the last four characters. That makes RIGHT the natural tool for serial numbers, file extensions, and any code whose end is regular while its start is not.
The default count is the trap. =RIGHT(A2) returns just "3", one character. Always type the count.
RIGHT and trailing spaces do not mix. =RIGHT(A7,4) returns "099 ", with the space in the last position and the final 9 pushed out of view. The result looks nearly right, which is worse than an error. =RIGHT(TRIM(A7),4) returns "0099". To use the serial as a number, wrap it: =VALUE(RIGHT(TRIM(A7),4)) returns 99.
Take a piece from the middle
MID needs a start and a length. For a fixed layout, count the positions. The site code in A2 starts at position 5 with three letters, so =MID(A2,5,3) returns "CPT".
But try the same formula on a row with a longer type. =MID(A4,5,3) on "DOCK-CPT-2025-0310" returns "-CP", because DOCK pushed the site code one place to the right. On "PHONE-DBN-2022-0007" it returns "E-D". The formula runs without any error and gives wrong answers, which is the danger of hard-coded positions on data that varies.
The fix is to find the first dash and start after it: =MID(A4,FIND("-",A4)+1,3) returns "CPT" on A4 and =MID(A5,FIND("-",A5)+1,3) returns "DBN" on A5.
Remove characters from the right in Excel
Removing characters from the right means keeping everything except the last N characters. Excel has no function that deletes from the end, so you keep the left part by computing its length.
=LEFT(A2,LEN(A2)-5)
LEN(A2) is 17. Subtract 5 for the "-0183" suffix and LEFT keeps 12 characters: "LAP-CPT-2024". The same formula on A5 returns "PHONE-DBN-2022", because the subtraction adapts to the length of each tag.
The trailing-space row shows the trap again. =LEFT(A7,LEN(A7)-5) removes five characters from an 18-character cell, and one of those five is the invisible space, so it returns "TAB-DBN-2024-" with a dash still attached. =LEFT(TRIM(A7),LEN(TRIM(A7))-5) returns "TAB-DBN-2024".
To remove characters from the left instead, use RIGHT with LEN: =RIGHT(A2,LEN(A2)-4) removes the first four characters of A2 and returns "CPT-2024-0183". When the amount to remove depends on a delimiter, use FIND: =RIGHT(A4,LEN(A4)-FIND("-",A4)) removes everything through the first dash and returns "CPT-2025-0310".
Anchor from the end when prefixes vary
Types vary in length, but the last nine characters of every tag follow the same pattern: year, dash, serial. Anchoring from the end sidesteps the variable start altogether.
- =LEFT(RIGHT(A2,9),4) returns "2024". RIGHT keeps "2024-0183", and LEFT takes its first four characters.
- =LEFT(RIGHT(A5,9),4) returns "2022" on the PHONE row, with no changes.
- =MID(A4,LEN(A4)-8,4) returns "2025" using the length to find the start.
Let FIND and LEN do the counting
FIND tells you where a delimiter sits, and LEN tells you how long the text is. Together with the four functions they remove the need to count by hand.
- Type: =LEFT(A4,FIND("-",A4)-1) returns "DOCK". On A5 it returns "PHONE". The minus 1 stops before the dash.
- Site: =MID(A2,FIND("-",A2)+1,3) returns "CPT". The plus 1 starts after the dash.
- Everything after the first dash: =RIGHT(A2,LEN(A2)-FIND("-",A2)) returns "CPT-2024-0183".
Nest the functions
One function can feed another. The inner function runs first, and its result becomes the text for the outer one. =LEFT(RIGHT(A2,9),4) is a nest: RIGHT gets "2024-0183" and LEFT gets "2024".
You can join pieces too. =MID(A2,5,3)&"/"&RIGHT(A2,4) joins the site and the serial with a slash and returns "CPT/0183".
The practical advice for building nests is to write the inner formula in its own cell first, check it, and then wrap the outer one around it. A nest you cannot read is a nest you cannot debug.
Clean the tag before you cut it
Row 7 proved the point: hidden spaces break position-based formulas silently. Run the cleanup first.
- =LEN(A7) returns 18, while =LEN(TRIM(A7)) returns 17. A quick audit formula is =IF(LEN(TRIM(A7))=17,"OK","Check"), which returns "OK" for A7 once trimmed. The same test on A4 returns "Check", since DOCK makes its tag 18 characters long. That is a reminder that length alone does not validate a tag whose type varies.
- =UPPER(TRIM(A7)) returns "TAB-DBN-2024-0099", clean and upper case.
Alternatives to the four functions
| Tool | Good for | Limit |
| TEXTBEFORE and TEXTAFTER | Text either side of a delimiter, such as =TEXTBEFORE(A2,"-") | Microsoft 365 and Excel 2024 only |
| TEXTSPLIT | Splitting a tag into columns at the dashes | Microsoft 365 and Excel 2024 only |
| Text to Columns | One-off split of a whole column on the dashes | Static; does not update when data changes |
| Flash Fill (Ctrl+E) | Quick patterns from an example you type | Guesses; check the results |
| COUNTIF with wildcards | Counting tags by a pattern, =COUNTIF(A2:A7,"*-2024-*") returns 2 | Counts, does not extract |
Excel versions
LEN, LEFT, RIGHT and MID are in every desktop version. Microsoft lists them for Microsoft 365 on Windows and Mac, Excel 2024, 2021, 2019 and 2016, and they work in Excel for the web. Their byte-based twins (LENB, LEFTB, RIGHTB, MIDB) are marked deprecated, so skip those.
TEXTBEFORE, TEXTAFTER and TEXTSPLIT are on Microsoft's list for Microsoft 365 and Excel 2024 on Windows and Mac, but not for Excel 2021 or 2019. The Microsoft pages do not mention Excel for the web, so test there by typing the name and watching for autocomplete.
Errors and their fixes
| What you see | Cause | Fix |
| #VALUE! from LEFT or RIGHT | A negative count, often from LEN minus a number larger than the text | Check that the text is longer than the number you subtract |
| #VALUE! from a FIND inside a formula | The delimiter is missing from the text | Wrap in IFERROR, or fix the text |
| #VALUE! from MID | start_num below 1 or a negative length | Start at 1 or more |
| A result that looks almost right | A trailing or leading space shifted the text | TRIM first |
| A number that will not add up | The extraction returned text | Wrap in VALUE |
| One character only | RIGHT or LEFT was typed without a count | Add the count |
| A cut in the wrong place on some rows | A fixed position on text of varying length | Use FIND, or anchor from the end |
What learners get wrong
Between 26 September and 3 November 2026, our LEFT, RIGHT, LEN and INDEX Practice lesson logged 4,317 first attempts, and 64.7% were right. These are first checks of a screen in a page view, not people.
The screen that asks learners to combine RIGHT and LEN to return "789" is the clearest example for this page. It drew 409 first attempts and 53.5% were right. The accepted answer is =right(a1,len(c1)): RIGHT takes its count from the length of another cell, so LEN supplies the number. The wrong answers show how learners tangle the roles:
- A missing closing bracket. 18 first attempts typed =right(a1,len(c1). Every opening bracket needs its partner, and the nest needs two closings at the end.
- LEN on the outside. 14 typed =right(len(a1),3) and 12 typed =right(len(c1),3). LEN returns a number, and RIGHT then cuts that number instead of the text you meant.
- Swapped arguments. 10 typed =right(len(c1),a1), putting the count where the text belongs and the text where the count belongs. The order is text first, count second.
- The functions in reverse. 8 typed =len(right(a1,3)), which measures the right three characters, always 3, instead of cutting by a measured length.
- The wrong cell. 7 used =right(a1,len(c3)). The structure was right, but the length came from a different row.
In our LEN, LEFT, and RIGHT Functions lesson, one screen asks for =RIGHT( on its own. 832 first attempts, half of them right, and the two most common wrong answers (175 and 156 first attempts) were =right(a2) and =right(). The first returns one character, as the default count says. The second omits the text.
The takeaway: write the question as a sentence before the formula. "Take the right N characters of this cell, where N is the length of that cell."
Worked scenario: audit a fixed-asset register
The finance team asks you to check the asset tags in the sample register, and to split them into columns for a depreciation schedule.
- Add a clean column. In B2 type =TRIM(A2) and fill down. Everything below points at column B, not at the raw tags.
- Split out the type. In C2 type =LEFT(B2,FIND("-",B2)-1). You get LAP, MON, DOCK, PHONE, LAP and TAB.
- Split out the year. In D2 type =MID(B2,LEN(B2)-8,4). You get 2024, 2023, 2025, 2022, 2025 and 2024.
- Split out the serial. In E2 type =RIGHT(B2,4), or =VALUE(RIGHT(B2,4)) if the schedule needs numbers.
- Count assets bought in 2024 with =COUNTIF(A2:A7,"*-2024-*"), which returns 2.
- Produce a tag without its serial for the ledger: =LEFT(B2,LEN(B2)-5) returns "LAP-CPT-2024" on row 2.
- Copy the finished columns and paste them as values before sending.
Practice the four functions
Reading the decision table is not the same as making the decision. Open Lesson 13, LEN, LEFT, and RIGHT Functions and type the formula from the exercise above this section. Then try Lesson 16, LEFT, RIGHT, LEN and INDEX Practice for nests that mix functions, and Lesson 62, LEN, LEFT, RIGHT, MID Practice to bring MID into the mix.
FAQ
What is the difference between LEFT, RIGHT and MID in Excel?
LEFT returns characters from the start of the text, RIGHT from the end, and MID from any position you choose. LEFT and RIGHT take a text and a count. MID takes a text, a start position and a count. Pick by where the piece sits in the text.
How do I remove characters from the right in Excel?
Keep the left part by subtracting from the length: =LEFT(A2,LEN(A2)-5) removes the last five characters. LEN counts the whole text, and LEFT keeps everything except the final five. If the amount varies, use FIND to locate where the unwanted part starts.
What does the Excel RIGHT function do?
RIGHT returns the last characters of a text. =RIGHT(A2,4) returns the final four characters, such as a serial number. If you omit the count, RIGHT returns only one character, so always include it. The result is text, even when it is made of digits.
Why does my LEFT or RIGHT formula return the wrong characters?
Usually a hidden space has shifted the text, or a fixed position was used on text of varying length. Compare =LEN(A7) with =LEN(TRIM(A7)) to spot hidden spaces. For varying lengths, find a delimiter with FIND, or count from the end of the text.
How do I use LEN with LEFT, RIGHT or MID?
LEN supplies the length so you do not count by hand. =LEFT(A2,LEN(A2)-5) drops the last five characters, and =MID(A2,LEN(A2)-8,4) starts eight places before the end. Use it whenever the cut point depends on how long each cell is.
Do these text functions work with numbers?
Yes, but they treat the number as plain text and return text. =LEFT(20261103,4) returns "2026" as text. Wrap the result in VALUE to turn it back into a number. Dates are stored as serial numbers, so these functions read the serial digits, not the displayed date.
Sources
Keep going
Guides people read next.
Excel Text Functions: Complete Guide to LEFT, MID, RIGHT, LEN, TRIM, SUBSTITUTE and More
Master Excel text functions: LEFT, MID, RIGHT, LEN, TRIM, UPPER, LOWER, SUBSTITUTE, REPLACE, FIND, SEARCH, CONCAT, TEXTJOIN, and TEXT with examples.
11 minINDEX MATCH vs VLOOKUP: Which Lookup Should You Use?
INDEX MATCH vs VLOOKUP compared: looking left, inserting columns, two-way lookups and how much each formula asks you to type. One worked example, one verdict.
5 minXLOOKUP vs VLOOKUP: Which to Use, with Examples
XLOOKUP vs VLOOKUP side by side: looking left, exact match by default, a built-in not-found message and the Excel versions that have each. One worked example.
5 min