Excel MID function

In Excel workbook, when you want to extract part of text from a cell value based on the location and length, the MID function can help you to solve this task. MID function is used to find and return a specific number of characters from the middle of given text string.


 Syntax:

The syntax for the MID function in Excel is:

=MID (text, start_num, num_chars)

 Arguments:

  • text: Required. The text string that you want to extract characters from.
  • start_num: Required. The location of the first character that you want to extract.
  • num_chars: Required. The total number of characters you want to extract.

Notes:

  • 1. If start_num is greater than the length of the original text, it will return an empty string ("").
  • 2. If start_num is less than 1, MID function returns the #VALUE! error value.
  • 3. If num_chars is negative, MID function will also return the #VALUE! error value.
  • 4. If the sum of start_num and num_chars greater than the total length of the original text string, the MID function will return the characters from start_num to the last character.

 Return:

Return the specific characters from the middle of text string.


 Examples:

Example 1: Basic uses of the MID function

For example, I want to extract 10 characters which begins at the third character from the list of text strings. Please enter this formula into a blank cell:

=MID(A2,3,10)


Example 2: Use MID function to extract first and last names from full names

We can also use the MID function to extract the first and last names from the full names, please do as follows:

Extract the first names from full names:

Please enter or copy the below formula into a blank cell where you want to output the result, and then drag the fill handle down to the cells you want to apply this formula, and all the first names have been extracted as following screenshot shown:

=MID(A2,1,SEARCH(" ",A2,1))

Extract the last names from full names:

Pull the last names from the full names, please apply the below formula:

=MID(A2,SEARCH(" ",A2),100)


Example 3: Use MID function to extract substrings between two delimiters

Sometimes, you may want to extract the text between the two dashes as below screenshot shown, to solve this task, combining the MID and FIND functions can help you.

Please copy the following formula into a blank cell:

=MID(A2, FIND("-",A2)+1, FIND("-", A2, FIND("-",A2)+1) - FIND("-",A2)-1)

And then, drag the fill handle down to fill this formula to other cells you need. And you will get the result as below screenshot shown:

Notes:

1. You can change the delimiter “-” to other separators as you need.

2. The above formula is applied to extract the text between the first and second occurrences of the specific delimiter.


 More Functions:

  • Excel SEARCH Function
  • The SEARCH function can help you to find the position of a specific character or substring from the given text string.
  • Excel REPLACE Function
  • The REPLACE function in Excel can help you to find and replace characters based on given location from text string with a new text.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.