This Excel tutorial explains how to use the Excel MID function with syntax and examples.
The Microsoft Excel MID function extracts a substring from a string (starting at any position).
The syntax for the MID function in Microsoft Excel is:
MID( text, start_position, number_of_characters )
The MID function can be used in the following versions of Microsoft Excel:
The MID function can be used in Microsoft Excel as the following type of 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 Excel spreadsheet above, the following 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"
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)
The variable LResult would now contain the value of "ab".
(scroll to see more)