MID and MIDB functions to cut strings in Excel
In the previous articles, I introduced you to LEFT () and RIGHT () to cut the string to the left and right of the text. In this article, I will introduce to you the MID (), MIDB () functions to cut the string from the position you want to start cutting the string.
The article describes the syntax and usage of MID () and MIDB () functions to cut strings in Excel.
Description
The MID () function returns a string from a text string, with the position to start extracting from the text string and the number of characters returned by the string that is specified. Functions used in languages use a single-byte character set (SBCS) and always count each character as 1.
The MIDB () function returns a string from a text string with the start of extraction and the specified number of bytes returned. The function counts each double-byte character as 2 when the default language is one of the languages that supports DBCS.
Syntax
= MID (text, start_num, num_chars)
= MIDB (text, start_num, num_bytes)
Inside:
- text: is the text string you want to extract the substring.
- start_num: is the starting position to extract characters from the text string, calculated from the left to (the first character in the text string is 1, the second character is 2 .).
- num_chars: the number of characters you want to extract from the text string.
- num_bytes: the number of bytes you want to extract from the text string.
Note
- If start_num is less than 1, the function returns the #VALUE! Error value.
- If start_num is greater than the length of the text string, the function returns the empty string.
- Start_num is smaller than the text length, but start_num + num_chars (num_bytes) is bigger than the text length, the function returns the string from star_num to the end of the text string.
- Num_chars, num_bytes must be a positive integer, if it is a negative number, the function returns an error value.
For example
So that you have learned about MID () and MIDB () string functions, you can combine them with other functions to achieve high efficiency in the process of string processing. Good luck!
You should read it
- Separate text from strings in Excel, for example, and how to do it
- Instructions for cutting strings, concatenating strings in Excel
- LEFT and LEFTB functions - Functions for cutting strings in Excel
- Summary of trigonometric functions in Excel
- How to use MID functions to get strings in Excel
- Split numbers from strings in Excel
- How to fix the SUM function doesn't add up in Excel
- Complete financial functions in Excel you should know
May be interested
- LOOKUP function searches in Excelthe lookup () function returns a value from a data range consisting of 1 column or 1 row, or from an array. the lookup () function is an improvement of the two functions vlookup () and hlookup () because it has the additional function to distinguish the search area as rows or columns.
- CELL function to look up information of a cell in Excelcell () returns the format, position, or content information of a cell depending on your needs. when you need to look up a cell's information, cell () is the most used function.
- LEFT and LEFTB functions - Functions for cutting strings in Excelleft () and leftb () are two string-cutting functions that are used a lot in string processing with excel spreadsheets. the left () and leftb () functions help you cut the string to the left of the text string as quickly and efficiently as possible.
- The OFFSET function returns a reference in Excelthe offset () function returns a reference to a range, a cell or a range of cells with the number of rows and columns specified by you. the return reference can be a cell or a range of cells that you can specify the number of rows and columns to return.
- The RAND function returns a random real number, greater than or equal to 0 and less than and equal to 1the rand () function returns a random real number, greater than or equal to 0 and less than and equal to 1.
- Summary of data functions in Excelthis article will summarize the functions and uses of each function in the data function group (database funtions) in excel.