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.
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
=LEFT(text, [num_chars])=RIGHT(text, [num_chars])=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:
=LEFT(A2, 4)returns WEST.
=RIGHT(A2, 3)returns INV.
=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
=LEFT(A2, 4)For EAST-1042-PAID, this returns EAST.
Step 2. Extract the invoice number
=MID(A2, 6, 4)This starts at character 6 and returns 4 characters, so it returns 1042.
Step 3. Extract the status
=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
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
| Issue | Cause | Fix |
|---|---|---|
| Wrong characters returned | Start position is off by one | Count the characters including hyphens and spaces |
| Formula works for one row only | Segment lengths vary | Use delimiter-based splitting instead |
| Hidden spaces appear | Source data has leading or trailing spaces | Wrap the source in TRIM |
| Number loses leading zeros | Extracted text is converted to a number | Keep 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.
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.
Expense Tracker
Log every expense, track receipts, and generate category summaries. Free template for personal or business use.
Open templateFinanceExpense Tracker for Contractors
Track contractor job materials, subcontractors, equipment, permits, mileage, and overhead by project with receipt review.
Open templateFinanceInvoice Template
Professional invoice template with automatic subtotal, tax, and total calculations. Customise with your logo and send in minutes.
Open templateFinanceReceipt Tracker Template
Log receipt IDs, merchants, categories, amounts, payment methods, document status, and follow-up actions in one review-ready workbook.
Open template