Excel - MIDB Function



MIDB Function

The Excel MIDB function retrieves a certain number of characters from the given string, and you need to specify the starting index and the number of bytes for extraction. MIDB Function allows you to work with the DBCS set gradually, which is used in foreign languages like Japanese, Chinese, etc. When you change the preferred language to DBCS-assisted languages in Excel, the MIDB function will calculate an independent double-byte character as 2. Otherwise, it will calculate each character as a unit number 1.

Compatibility

The MIDB function is compatible with the following versions of MS-Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016

Syntax

The syntax of MIDB function is as follows −

=MIDB(text, start_num, num_bytes)

Arguments

You can use the following arguments with the MIDB function −

Argument Description Required / Optional
Text It specifies the text string Required
start_num The starting point in the text string from where the character will be fetched. Required
num_bytes It specifies the number of bytes that you want to fetch. Required

Points to Remember

  • If the start_num comprises a negative value, the MIDB function will retrieve the #VALUE! error.
  • If the num_bytes argument contains a negative value, then the MIDB function will retrieve the #VALUE! error.
  • Ensure that the preferred language should be DBCS-supported languages like Korean, Chinese (Simplified), and Japanese.
  • For the English language, the MIDB function will behave like the MID function.

Examples of MIDB Functions

Practice the following example to learn the use of the MIDB function in Excel.

Example 1

Apply the MIDB function in a mixed set of languages.

Solution

Step 1 − First, consider the sample dataset, which is comprised of two columns titled Full Name and MIDB function. A column contains a list of Employees with their complete names. The employee's middle name is written in Korean in this column. You can use the Translate option to convert the middle name into English.

Step 2 − After that, enter the formula =MIDB(B3,9,3) in the C3 cell and press the Enter tab.

MIDB Function in Excel

MIDB Function in Excel 1

Step 3 − Moreover, select the C3 cell, drag the + sign(fill handle), and drop it to the C7 cell to fill the remaining cell values.

MIDB Function in Excel 2

Example 2

If the start_num comprises a negative value, the MIDB function will retrieve the #VALUE! error.

Solution

Double-click on the E4 cell, write the formula =MIDB(B3,-2,4) in the E4 cell, and press Enter tab. Here, the second argument is -2 which is invalid.

MIDB Function in Excel 3

Therefore, the MIDB function will return the #VALUE! error. You can alter the second argument value and set its positive number.

MIDB Function in Excel 4

Example 3

If the num_bytes argument contains a negative value, then the MIDB function will retrieve the #VALUE! error.

Solution

Select the E2 cell and enter the formula =MIDB(B3,3,-4). Here, the third argument, num_bytes, contains a negative value of -4, which is not permissible.

MIDB Function in Excel 5

Once you press the Enter button, the MIDB function will return the #VALUE! error.

MIDB Function in Excel 6

Download Practice Sheet

You can download and use the sample data sheet to practice the MIDB function.

Advertisements