How to use MID, MIDBs function in Excel?

The `MID` and `MIDB` functions in Excel are text functions used to extract a substring from a string. Here’s how you can use each of them:

MID Function

Syntax:

MID(text, start_num, num_chars)
  • `text`: The original string from which you want to extract a substring.
  • `start_num`: The position of the first character you want to extract. The first character in `text` is 1.
  • `num_chars`: The number of characters you want to extract from the `text`.

Example:

Suppose you have the string “ExcelFunctions” in cell A1 and you want to extract “Excel”:

=MID(A1, 1, 5)

This extracts 5 characters from the start of the string “ExcelFunctions”, starting from the first character.

MIDB Function

The `MIDB` function is similar to the `MID` function but is used with double-byte character set (DBCS) languages, such as Japanese, Chinese, and Korean.

Syntax:

MIDB(text, start_num, num_bytes)
  • `text`: The original string from which you want to extract a substring.
  • `start_num`: The position in bytes of the first character you want to extract. The first character in `text` is 1.
  • `num_bytes`: The number of bytes you want to extract.

Example:

If you are working with a string composed of DBCS characters, the `MIDB` function allows you to specify the start position and the length in bytes rather than in characters. However, if your system’s default language setting is not set to a DBCS language, `MIDB` behaves the same as `MID`.

Important Notes:

  • Use `MID` when working with regular text strings.
  • Use `MIDB` when working with DBCS languages for proper handling of character bytes.
  • If you try to extract more characters than are available in the string, both functions will return the remaining characters without error.

Using these functions, you can effectively manage strings and data extraction in Excel for various text manipulation tasks.

Unlock Your Potential

Excel

Basic - Advanced

Access

Access Basic - Advanced

Power BI

Power BI Basic - Advanced

Help us grow the project