Hardware

How to use the MID and MIDB function in Microsoft Excel


MID and MIDB functions are both text functions in Microsoft Excel. 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. The MID function counts each character single-byte or double-byte as one, no matter the default language.

The formula for the MID function is MID(text, start_num, num_chars). The MIDB function returns a specific number of characters from a text string starting at the position you specify; based on the number of bytes you specify. The formula for the MIDB function is MIDB(text,start_num, num_bytes).

The Syntax for the MID function

  • Text: The string containing the characters you want to extract. It is required.
  • Start_num: The position of the first character you want to extract. If the Start_num is greater than the length of text, MID will return an empty text. If the Start_num is less than one, then the MID will return the error value #VALUE.
  • Num_chars:  Identifies the number of characters you want MID to return from the text. It is required.

The Syntax for the MIDB function

  • Text: The string containing the characters you want to extract. It is required.
  • Start_num: The position of the first character you want to extract. If the Start_num is greater than the length of text, MIDB will return an empty text. If the Start_num is less than one, then the MIDB will return the error value #VALUE.
  • Num_Bytes: Identifies the number of characters you want MIDB to return from the text in bytes.

How to use the MID function in Excel

Open Microsoft Excel.

Use an existing table or create one.

In the cell where you want to place the result type =MID(A3,4,2).

A3 is the string containing the characters you want to extract.

4 is the position of the first character you want to extract.

2 is the number of characters you want MID to return from the text.

Press Enter on the keyboard to see the result.

If you drag the fill handle down, you can see the other results, and you can change the Start_num and the Num_chars if desired.

There are two other methods to use the MID function.

Method one is to click the fx button on the top left of the Excel spreadsheet.

An Insert Function dialog box will pop up.

In the Select a Category section, click Text from the list box.

In the Select a Function section, select the MID  function from the list box.

Then click OK.

A Functions Arguments dialog box will pop up.

In the dialog box in the Text section, enter into its box A3.

In the Start_num section, enter into its box 4.

In the Num_chars section, enter into its box 2.

Then OK.

Method two is to click the Formulas tab.

In the Function Library group, click Text.

In the drop-down list, click MID.

A Functions Arguments dialog box will appear.

Follow steps of the Functions Arguments in method one.

Read: How to create a Combination Chart in Excel.

How to use the MIDB functionin Excel

Enter into the cell where you want to enter the result =MIDB(A3,4,5).

You will notice that the MIDB function will give you the same result as the MID function.

The MIDB function will only count each double-byte character by two;  if you enable the editing of a language that supports DBCS and set it as the default language.

The language that supports DBCS includes Japanese, Chinese, and Korean.

Therefore, if no language supports DBCS, MIDB will count each character like the MID function.

We hope this tutorial helps you understand how to use the MID and MIDB function in Excel.


You may also like...