Text
All versions
◉ 8 views
=MID()
MID returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.
Applies To:
Excel for Microsoft 365Excel for Microsoft 365 for MacExcel 2024Excel 2024 for MacExcel 2021Excel 2021 for MacExcel 2019Excel 2016
=MID(text, start_num, num_chars)
Hover argument names in the table for details.
Output typeText
Popularity65 / 100
VolatileNo
Dynamic ArrayNo
📥 Download sample .xlsx — Coming soon
▦ Try in Playground
Dedicated file for this function — safe & lightweight · sample data + live formulas
⬇ Download Sample Workbook
A dedicated .xlsx for =MID() with Persian sample data & live formulas — open in Excel and practice.
- Sheet “Sample” — data table + formula in place
- Sheet “Guide” — syntax, arguments & tips from this page
- Instant & secure (token + rate limit)
🧠 🧠 Quiz this function
%d questions — syntax, example & errors — test yourself!
◧ Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
text |
Any type | Required | The text string containing the characters you want to extract. |
start_num |
Any type | Required | The position of the first character you want to extract in text. The first character in text has start_num 1, and so on. If start_num is greater than the length of text, MID returns "" (empty text). If start_num is less than the length of text, but start_num plus num_chars exceeds the length of text, MID returns the characters up to the end of text. If start_num is less than 1, MID returns the #VALUE! error value. |
num_chars |
Any type | Required | for MID. Specifies the number of characters you want MID to return from text. If num_chars is negative, MID returns the #VALUE! error value. |
▣ Examples
۵ نویسه از رشته داخل A2 را از نویسه اول برمیگرداند.
=MID(A2,1,5)
۲۰ نویسه از رشته داخل A2 را از نویسه هفتم برمیگرداند؛ چون تعداد درخواستی (۲۰) از طول رشته (۱۰) بیشتر است، تمام نویسهها از هفتم تا انتها برگردانده میشود و نویسه خالی اضافه نمیشود.
=MID(A2,7,20)
چون نقطه شروع بزرگتر از طول رشته (۱۰) است، متن خالی برگردانده میشود.
=MID(A2,20,5)
✦ Tips
- The MIDB function is deprecated. In workbooks set to Compatibility Version 2, MID has improved behavior with Surrogate Pairs, counting them as one character instead of two. Variation Selectors (commonly used with emojis) will still be counted as separate characters. Read more here: The Unicode standard
⚠ Common Errors
#VALUE!
If start_num is less than 1, MID returns the #VALUE! error value. If num_chars is negative, MID returns the #VALUE! error value.
Fix: Check the second and third arguments
💬 Comments & Q&A 0 approved
🔒 Your comment will be published after review.Share your thoughts — visible after admin approval
No comments yet — be the first!