MID和MIDB函数都是Microsoft Excel中的文本函数。MID从您指定的位置开始的文本字符串中返回特定数量的字符;根据您指定的字符数。MID函数将每个字符单字节或双字节计为一个,无论默认语言如何。
MID函数的公式是MID(text, start_num, num_chars)
。MIDB函数从您指定的位置开始的文本字符串中返回特定数量的字符;根据您指定的字节数。MIDB函数的公式是MIDB(text,start_num, num_bytes)
。
MID 函数的语法
- Text:包含要提取的字符的字符串。这是必需的。
- Start_num:要提取的第一个字符的位置。如果Start_num大于文本长度,MID将返回一个空文本。如果Start_num小于 1,则MID将返回错误值#VALUE。
- Num_chars:标识您希望 MID 从文本中返回的字符数。这是必需的。
MIDB 函数的语法
- Text:包含要提取的字符的字符串。这是必需的。
- Start_num:要提取的第一个字符的位置。如果Start_num大于文本长度,MIDB将返回一个空文本。如果Start_num小于 1,则MIDB将返回错误值#VALUE。
- Num_Bytes:标识您希望 MIDB 从文本中返回的字符数(以字节为单位)。
Excel中(Excel)MID函数的使用方法
打开 Microsoft Excel。
使用(Use)现有表或创建一个。
在要放置结果类型=MID(A3,4,2)的单元格中。
A3是包含要提取的字符的字符串。
4是要提取的第一个字符的位置。
2是您希望 MID 从文本中返回的字符数。
按键盘上的Enter键查看结果。
如果您向下拖动填充手柄,您可以看到其他结果,并且您可以根据需要更改Start_num和Num_chars。
有两种其他方法可以使用MID功能。
方法一是单击Excel电子表格左上角的fx按钮。
将弹出插入函数(Insert Function)对话框。
在选择类别(Select a Category)部分中,单击列表框中的文本(Text)。
在选择函数(Select a Function)部分, 从列表框中选择MID函数。(MID)
然后单击确定(OK)。
将弹出一个函数参数(Functions Arguments)对话框。
在文本(Text)部分的对话框中,在其框中输入A3。
在Start_num部分中,输入其框 4。
在Num_chars部分,输入框 2。
然后确定(OK)。
方法二是单击“公式(Formulas)”选项卡。
在函数库(Function Library)组中,单击文本(Text)。
在下拉列表中,单击MID。
将出现一个函数参数(Functions Arguments)对话框。
遵循方法一中函数参数的步骤。(Functions Arguments)
阅读(Read):如何在 Excel 中创建组合图(How to create a Combination Chart in Excel)。
如何在Excel中使用(Excel)MIDB功能
输入(Enter)要输入结果的单元格=MIDB(A3,4,5)。
您会注意到MIDB函数将给出与(MIDB)MID函数相同的结果。
MIDB函数只会将每个双字节字符计数为 2;如果您启用了支持DBCS的语言的编辑并将其设置为默认语言。
支持DBCS的语言包括日文、中文和韩文(Korean)。
因此,如果没有语言支持DBCS,MIDB将像(MIDB)MID函数一样计算每个字符。
我们希望本教程能帮助您了解如何在Excel中使用(Excel)MID和MIDB函数。
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.