In previous articles, we've introduced you to the LEFT() and RIGHT() functions for cutting characters from the left and right sides of a text string. In this piece, we'll introduce you to the MID() and MIDB() functions for slicing characters from any desired position.

This article describes the syntax and usage of the MID() and MIDB() functions for string slicing in Excel.
Description
The MID() function retrieves a string of characters from a text string, starting from a specified position in the text and returning a specified number of characters. This function is used in languages that utilize single-byte character sets (SBCS) and always counts each character as 1.
The MIDB() function retrieves a string of characters from a text string, starting from a specified position and returning a specified number of bytes. It counts each double-byte character as 2 in languages that support double-byte character sets (DBCS).
Syntax
=MID(text, start_num, num_chars)
=MIDB(text, start_num, num_bytes)
Where:
- text: the text string from which you want to extract substring characters.
- start_num: the starting position for character extraction within the text string, counted from left to right (the first character in the text string is 1, the second character is 2, and so on).
- num_chars: the number of characters you want to extract from the text string.
- num_bytes: the number of bytes you want to extract from the text string.
Note
- If start_num is less than 1, the function returns the #VALUE! error.
- If start_num exceeds the length of the text string, the function returns an empty string.
- If start_num is less than the length of the text string but start_num + num_chars (or num_bytes) exceeds the length of the text string, the function returns a substring from start_num to the end of the text string.
- Num_chars and num_bytes must be positive integers; if negative, the function returns an error value.
Example

Congratulations on mastering MID() and MIDB() string slicing functions! You can now combine them with other functions to achieve high efficiency in string processing. Best of luck to you all!
