The Excel Mid function returns a specified number of characters from the middle of a supplied text string.
The syntax of the function is :
|text||-||The original text string.|
|start_num||-||An integer that specifies the position of the first character that you want to be returned.|
|num_chars||-||An integer that specifies the number of characters (beginning with start_num), to be returned from the supplied text.|
Note that the Mid function always returns a text string, even though this may be contain digits and therefore may look like a number. This should be borne in mind if you wish to use the result of the function within further formulas.
The spreadsheet below shows three examples of the Excel Mid function.
Note that the example in cell B3 returns the text value "5". Although the text string contains a number, this is stored as a text string in Excel. Excel Data Types are explained further on the Excel Formatting page.
Further information and examples of the Excel Mid function are provided on the Microsoft Office website.
If you get an error from the Excel Mid function, this is likely to be the #VALUE! error:
Also, some users encounter the following problem:
Dates are stored in Excel as numbers, and it is only the cell formatting that makes them appear as dates in your spreadsheet. Therefore, if you attempt use the Left, Mid or Right function on a date, the function will return the start, mid or end characters of the number that represents that date.
For example, 01/01/1980 is represented by the number 29221, so applying the Mid function to a cell containing the date 01/01/1980 (and requesting that 2 characters, starting from the 2nd character) would result in a returned value of "92".