Text
1.3K monthly searches
Beginner
4 min read

MID Formula in Excel - Extract Text from Middle of String

Extract specific characters from the middle of text strings with the MID function in Excel....

Quick Start

Syntax

=MID(text, start_num, num_chars)

Parameters

text - Required. The text string containing the characters you want to extract

start_num - Required. Position of first character to extract (1 = first character)

num_chars - Required. Number of characters to extract from the text string

Simplest Example

AB
1Product CodeSerial Number
2SKU-123456-XYZ
3Formula:
=MID(A2, 5, 6)
123456

Quick Reference

Extract Fixed Position
=MID("Product-12345", 9, 5)

Extract 5 chars starting at position 9

=MID(...) → "12345"

Extract Middle Word
=MID("Hello World Excel", 7, 5)

Extract "World" from text

=MID(...) → "World"

Dynamic Start with FIND
=MID(A1, FIND(":", A1)+1, 100)

Extract everything after colon

A1="Code: ABC123" → "ABC123"

Extract Between Delimiters
=MID(A1,FIND("[",A1)+1,FIND("]",A1)-FIND("[",A1)-1)

Get text between square brackets

A1="Name [Code]" → "Code"

Real-World Examples

Extract Serial Numbers from SKUs

Parse product serial numbers from structured SKU codes in inventory management systems. The MID function in Excel extracts the middle portion of SKU strings where serial numbers are consistently positioned. This Excel MID formula is critical for inventory tracking, warehouse management systems, order processing automation, and supply chain analytics. Use when your SKUs follow a fixed format like "SKU-XXXXXX-YYZ" where serial numbers always occupy positions 5-10, enabling automated data extraction for barcode scanning, inventory reconciliation, and product lifecycle tracking across enterprise resource planning systems.

ABC
1ProductSKU CodeSerial Number
2LaptopSKU-123456-ABC
3MouseSKU-789012-DEF
4Formula:
=MID(A2, 5, 6)
123456
Pro Tip: Combine MID with FIND for variable-length prefixes: =MID(A1, FIND("-",A1)+1, 6)
Pattern: =MID(text, fixed_start, fixed_length) for consistent formats
Parse Account Numbers from Transaction IDs

Extract account numbers embedded within composite transaction identifiers for financial reporting and reconciliation. The Excel MID function isolates specific account digits from standardized transaction codes used by banking systems, payment processors, and accounting software. This MID formula in Excel enables automated account matching, transaction categorization, and compliance reporting. Essential for finance teams processing thousands of transactions daily, where account numbers consistently appear at the same position within transaction IDs, allowing bulk data extraction for audit trails, regulatory reporting, and financial data analytics.

ABC
1TransactionTransaction IDAccount
2Payment 1TXN2025-4567-890
3Formula:
=MID(A2, 9, 4)
4567
Pattern: =MID(txn_id, start_position, account_length) for financial data parsing

Common Mistakes to Avoid

=MID("Hello", 0, 3)Using 0 or negative start position

❌ The Problem:

  • Excel positions start at 1, not 0 like some programming languages
  • Returns #VALUE! error when start_num is less than 1
  • Common mistake for users familiar with JavaScript or Python

✅ Solution:

=MID("Hello", 1, 3)

In Excel MID function, positions are 1-indexed. First character is position 1, not 0. Use start_num=1 for the first character. This is consistent with other Excel text functions like LEFT and RIGHT.

=MID(A1, 5, 10) when A1 has only 8 charactersRequesting more characters than available

❌ The Problem:

  • If start position + length exceeds text length, returns all available chars
  • May return less data than expected
  • Can cause issues in data validation or downstream processing

✅ Solution:

=MID(A1, 5, MIN(10, LEN(A1)-4))

Protect against over-extraction by calculating available characters: MIN(desired_length, LEN(text)-start_num+1). The Excel MID function won't error but returns fewer characters than requested, which may break your data workflow if not handled properly.

=MID(A1, 5, 0)Using 0 for number of characters

❌ The Problem:

  • Returns empty string when num_chars is 0 or negative
  • No error, but produces blank result
  • May be unintended when calculating dynamic lengths

✅ Solution:

=IF(calculated_length>0, MID(A1, 5, calculated_length), "")

When using calculated lengths, validate that num_chars is positive. The MID function in Excel returns empty string for zero or negative lengths. Add conditional logic to handle edge cases in dynamic text extraction scenarios.

Frequently Asked Questions

Other Text Functions

Related Formulas

Master these MID variants:

Master Excel MID

From basics to advanced - AI generates perfect formulas instantly.