# MID in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/mid/

MID cuts a fixed number of characters out of a text, starting at a position you choose. It suits codes with a fixed layout, such as SKUs, phone numbers and dates stored as text.

## Syntax

```
MID(string, starting_at, extract_length)
```

## Arguments

- `string` (string, required: yes): The text to cut from. A number is converted to text first.
- `starting_at` (number, required: yes): The position of the first character to return, counted from 1.
- `extract_length` (number, required: yes): How many characters to return. A value past the end of the text just returns what is left.

## Examples

The examples use this table, starting in A1:

| Code | Text |
|---|---|
| SKU-4821-RED | Google Sheets |
| AB | x |

```
=MID(A2, 5, 4)
```

Result: `4821`

Four characters starting at position 5 of the code: the middle number. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=VALUE(MID(A2, 5, 4)) + 1
```

Result: `4822`

MID returns text. VALUE turns it into a number before the +1, and makes comparisons with numbers work. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=MID(A2, SEARCH("-", A2) + 1, 4)
```

Result: `4821`

The start is found with SEARCH, so the formula still works if the prefix changes length. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=MID(B2, 8, 100)
```

Result: `Sheets`

A length larger than the text is fine: you get everything from position 8. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=MID(12345, 2, 3)
```

Result: `234`

A number is accepted as the string. The three characters from position 2 are 234. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- Positions start at 1. A starting_at of 0 returns #NUM!, and a negative extract_length returns #VALUE!.
- A start beyond the end of the text returns an empty string, not an error, so a broken formula can look like a blank cell.
- The result is always text, even when it looks like a number: MID(A2,5,4)=4821 is FALSE. Wrap it in VALUE before comparing.

## Compared with Excel

Same syntax in Excel.

## Related functions

- [LEFT](https://goingstellar.ro/reference/sheets/left/)
- [RIGHT](https://goingstellar.ro/reference/sheets/right/)
- [LEN](https://goingstellar.ro/reference/sheets/len/)
- [SEARCH](https://goingstellar.ro/reference/sheets/search/)
- [FIND](https://goingstellar.ro/reference/sheets/find/)
- [REGEXEXTRACT](https://goingstellar.ro/reference/sheets/regexextract/)

## Sources

- [MID (Docs Editors Help)](https://support.google.com/docs/answer/3094129)

