The Google Sheets MID function extracts a specific number of characters from the middle of a text string, starting at a specified position. It’s useful for splitting data like IDs, codes, or dates embedded in longer strings. No special setup is required—just ensure your source data is in a cell or directly typed into the formula.

What You'll Need

  • A Google Sheets spreadsheet
  • A cell containing the full text string you want to extract from
  • Knowledge of the starting position and number of characters to extract

Step-by-Step

  1. Open your Google Sheets document and click the cell where you want the result to appear.
  2. Enter the formula: =MID(text, start_position, num_chars), replacing each placeholder with your actual values:
    • text is the text string or cell reference (e.g., A2 or "Project-12345-End")
    • start_position is the position of the first character you want to extract (counting from 1)
    • num_chars is how many characters to return
  3. Press Enter to complete the formula. The result appears immediately in the cell.
  4. Drag the fill handle (small blue square in the bottom-right corner of the cell) down or across to apply the formula to other rows or columns.
  5. Verify the output by comparing it to your original text. For example, if cell A2 contains INV-2024-X99 and you use =MID(A2, 5, 4), the result should be 2024.

Common Mistakes

  • Off-by-one errors: Forgetting that start_position counts from 1, not 0. In ABC123, A is position 1, B is 2, etc.
  • Missing or negative num_chars: If num_chars is 0, the result is blank. If negative, the formula returns a #VALUE! error.
  • Using text instead of cell references carelessly: When typing text directly (e.g., =MID("ABC123",2,3)), enclose the string in double quotes. Forgetting quotes causes errors.
  • Assuming spaces don’t count: Spaces are characters too. In John Doe, the space between John and Doe is position 5.

Tips

  • Combine with LEN for dynamic extraction: Use =LEN(A2) to find total length, then subtract to extract from the end. For example, to get the last 3 characters: =MID(A2, LEN(A2)-2, 3).
  • Use FIND or SEARCH for variable positions: If the start point isn’t fixed, nest =MID(A2, FIND("-", A2)+1, 4) to start right after the first hyphen.
  • Handle inconsistent spacing or formatting: Wrap your formula with TRIM to clean extra spaces: =MID(TRIM(A2), 2, 5).
  • Check for hidden characters: If your formula returns unexpected results, use =CODE(MID(A2,1,1)) to see the ASCII code—non-printable characters (like line breaks) may affect positioning.
  • Copy and paste values if needed: After verifying, right-click > Copy, then Paste special > Values only to replace formulas with static results.

Troubleshooting

If your MID function returns an error or unexpected result, follow these steps:

  1. Check syntax: Ensure all arguments are present and separated by commas (not semicolons, unless your locale uses them). Example: =MID(A1,3,2) is correct; =MID(A1 3 2) is not.
  2. Verify start_position and num_chars: Confirm the start position is ≥1 and ≤ length of text, and num_chars is ≥0. If start_position + num_chars - 1 exceeds text length, Google Sheets returns only up to the end of the string (no error).
  3. Inspect the source cell: Right-click the cell > Format > Number > Plain text to ensure no number formatting masks leading zeros (e.g., 00123 may display as 123 if formatted as a number).
  4. Test with a simple string: Enter ABCDEFG in cell A1 and try =MID(A1,3,2). It should return CD. If not, the issue is likely with your sheet settings.
  5. Check locale settings: Go to File > Settings > General and confirm the list separator matches your formula (comma or semicolon). Mismatched separators cause #NAME? or #ERROR!.
  6. Clear formatting issues: If the result shows #VALUE!, make sure text isn’t a range (e.g., A1:A3)—MID only works on single text values. Use CONCAT or TEXTJOIN first if combining multiple cells.

Frequently Asked Questions

Does MID work with numbers?

Yes, but Google Sheets converts numbers to text first. For example, =MID(12345,2,2) returns 23. However, the result is always text, so use VALUE() to convert back to a number if needed: =VALUE(MID(12345,2,2)).

Can I extract text from multiple cells at once with one MID formula?

No. MID processes one text string per cell. Use =ARRAYFORMULA(MID(A2:A10,2,3)) to apply it across a range, but note that this requires the formula to be entered in the first cell of a blank column and may behave differently than standard formulas.

How is MID different from LEFT and RIGHT?

LEFT(text, num_chars) extracts from the beginning; RIGHT(text, num_chars) extracts from the end; MID(text, start_position, num_chars) starts at any position. For example, =LEFT("hello",2) returns he, while =MID("hello",2,2) returns el.

Why does my MID formula return blank when I expect characters?

Common causes: start_position is greater than the text length, num_chars is 0, or the source cell is truly blank (not just empty-looking). Double-check the source cell’s content by selecting it and looking in the formula bar.

Does MID handle Unicode or special characters?

Yes—each Unicode character (including emojis, accented letters, and non-Latin scripts) counts as one position. For example, in café, é is position 4. However, some combined characters (like accents over letters) may be stored as multiple code points, so test with your specific data.

Can I use MID with dates?

Only if the date is stored as text. If cell A1 contains a real date (e.g., 12/25/2024), =MID(A1,1,4) returns 12/2 because dates are stored as serial numbers internally. To extract parts of a date, use YEAR(), MONTH(), or DAY() instead. If the date is text (e.g., entered as "2024-12-25"), MID works as expected.