Home Privacy Policy Feedback Link to us Site Map Forums

Excel: Mid Function


In Excel, the Mid function extracts a substring from a string (starting at any position).

The syntax for the Mid function is:

Mid( text, start_position, number_of_characters )

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:

  • Excel 2007, Excel 2003, Excel XP, Excel 2000

For example:

Let's take a look at an example:

Based on the Excel spreadsheet above:

=Mid(A1, 5, 4) would return "abet"
=Mid(A2, 7, 3) would return "The"
=Mid("Excel", 1, 2) would return "Ex"

VBA Code

The Mid function can also be used in VBA code. For example:

Dim LResult As String

LResult = Mid("Alphabet", 5, 2)

The variable LResult would now contain the value of "ab".