Skip to content
Blog/Excel
Excel

How to Use LEFT, RIGHT, and MID in Excel

LEFT, RIGHT, and MID extract characters from text. Use them to clean IDs, split codes, pull dates, and standardize imported data.

Do this with AI

Try Griddy free

Start in your browser. Also works with Excel and Google Sheets.

By Justin Freels//6 min read

LEFT, RIGHT, and MID extract specific characters from text. They help when imported data arrives as combined codes, messy IDs, account strings, or labels that need cleanup before lookup or reporting.

Use these functions when the structure is predictable: the first three characters always mean region, the last four always mean year, or the middle segment always contains a project code.

The syntax

fx
=LEFT(text, [num_chars])
fx
=RIGHT(text, [num_chars])
fx
=MID(text, start_num, num_chars)
  • text - the cell containing the text
  • [num_chars] - how many characters to return
  • start_num - the character position where MID should start

If A2 contains WEST-0426-INV, then:

fx
=LEFT(A2, 4)

returns WEST.

fx
=RIGHT(A2, 3)

returns INV.

fx
=MID(A2, 6, 4)

returns 0426.

Example: split invoice codes

Suppose your invoice export uses codes like:

EAST-1042-PAID
WEST-1188-DUE

You want separate fields for region, invoice number, and status.

Step 1. Extract the region

fx
=LEFT(A2, 4)

For EAST-1042-PAID, this returns EAST.

Step 2. Extract the invoice number

fx
=MID(A2, 6, 4)

This starts at character 6 and returns 4 characters, so it returns 1042.

Step 3. Extract the status

fx
=RIGHT(A2, 4)

For EAST-1042-PAID, this returns PAID. For WEST-1188-DUE, the same formula would be wrong because DUE has only three characters.

WATCH OUT

LEFT, RIGHT, and MID work best when the text length is consistent. If each segment has a different length, use TEXTSPLIT or helper formulas instead.

When these formulas break

These functions count character positions. They do not understand words, separators, or business meaning. Excel is just counting.

That means the formula can break if:

  • one region has three letters and another has four
  • invoice numbers change from four digits to five
  • a source system adds a prefix
  • spaces appear before or after the code

When the delimiter is reliable, newer Excel users may prefer TEXTSPLIT. LEFT, RIGHT, and MID are still useful when the layout is fixed and compatibility matters.

Common issues

IssueCauseFix
Wrong characters returnedStart position is off by oneCount the characters including hyphens and spaces
Formula works for one row onlySegment lengths varyUse delimiter-based splitting instead
Hidden spaces appearSource data has leading or trailing spacesWrap the source in TRIM
Number loses leading zerosExtracted text is converted to a numberKeep the result as text

Validate lengths and edge cases

Text extraction formulas assume a consistent shape. Before filling them down, check for blank cells, shorter-than-expected IDs, extra delimiters, and non-printing characters. LEFT and RIGHT return the requested number of characters, while MID starts at a position and takes a count; an incorrect position can silently produce a plausible but wrong code.

Keep the raw field beside the extracted columns until the cleanup is approved. If the layout changes often, use delimiter-aware functions or Power Query instead of hard-coded character positions. Add a simple validation column that compares the reconstructed text with the source or flags unexpected lengths, then review the exceptions before using the extracted values in a lookup.

The Griddy way

Text extraction is easy for one row. A messy export with 600 rows is a different story.

"Split these invoice codes into region, invoice number, and status columns"

Griddy can inspect the pattern, choose fixed-position or delimiter-based formulas, and fill the cleaned fields across the sheet.

Sources

Do this with AI

Turn the instructions into a finished spreadsheet.

Tell Griddy what you need in plain English, then inspect and keep editing the result in the browser, Excel, or Google Sheets.

Try Griddy freeStart in your browser. No download required.
Also works withExcel Google Sheets

Use this on real templates

Clean imported IDs before they break the workflow

Text extraction is useful when expense exports, invoice codes, and receipt records arrive with multiple fields packed into one cell.

Finance