This Excel tutorial explains how to use the Excel MID function with syntax and examples.
start_position indicates the position in the string that you will begin extracting from. The first position in the string is 1.
number_of_characters indicates the number of characters that you wish to extract.
Based on the spreadsheet above, the following Excel MID examples would return:
Let's look at some Excel MID function examples and explore how to use the MID function in Excel VBA code:
Description
The Microsoft Excel MID function extracts a substring from a string (starting at any position).Syntax
The syntax for the Microsoft Excel MID function is:MID( text, start_position, number_of_characters )
Parameters or Arguments
text is the string that you wish to extract from.start_position indicates the position in the string that you will begin extracting from. The first position in the string is 1.
number_of_characters indicates the number of characters that you wish to extract.
Applies To
The MID function can be used in the following versions of Microsoft Excel:- Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Type of Excel Function
The MID function can be used in Microsoft Excel as the following type of function:- Worksheet function (WS)
- VBA function (VBA)
Example (as Worksheet Function)
Let's look at some Excel MID function examples and explore how to use the MID function as a worksheet function in Microsoft Excel:Based on the spreadsheet above, the following Excel MID examples would return:
=MID(A1, 5, 4) Result: "abet" =MID(A2, 7, 3) Result: "The" =MID("Excel", 1, 2) Result: "Ex" =MID("Techonthenet.com", 5, 6) Result: "onthen"
Example (as VBA Function)
The MID function can also be used in VBA code in Microsoft Excel.Let's look at some Excel MID function examples and explore how to use the MID function in Excel VBA code:
Dim LResult As String LResult = Mid("Alphabet", 5, 2)