MID

Using the Excel MID Function

Summary

The Excel MID function returns a given number of characters, starting at a specified point within a text string, based on the number of characters you specify. The MIDB function performs the same, with the exception that it returns characters based on the number of bytes a user specifies.

Use MID when working with single-byte character sets (SBCS) and MIDB when working with double-byte character sets (DBCS). Supported DBCS languages include Japanese, Chinese (Simplified and Traditional), and Korean.

When working with a DBCS language, MIDB counts each double-byte character as 2. Otherwise, the function counts each character as 1.


Syntax

=MID (text, start_num, num_chars)

=MIDB (text, start_num, num_bytes)


Syntax Breakdown

Text
Required. A text string.

Start Num
Required. The position of the first character you wish to extract from text. The first character in a text string is in position 1. Use the FIND or SEARCH functions if you don't know the location of start_num in advance.

Start_num returns empty set ("") if it is greater than the length of text.

If the argument is less than the length of text, but start_num combined with num_chars is greater than the length of text, the function returns the characters up to the end of the string.

Num Chars
Required. Used with MID, the number of characters you want the function to return.

Num Bytes
Required. Used with MIDB, the number of characters, in bytes, you want the function to return.


Usage Notes

The MID and MIDB functions return a given number of characters from a text string starting at a user specified point within the string.

MID #VALUE! Errors
The MID function will return the #VALUE! error in the following circumstances:

  1. Start_num is < 1;
  2. Num_chars is negative;
  3. Num_bytes is negative

Excel MID Function VALUE Error