EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • All Courses
    • All Specializations
  • Blog
  • Enterprise
  • Free Courses
  • All Courses
  • All Specializations
  • Log in
  • Sign Up
Home Excel Excel Resources TEXT and String Functions in Excel MID Function in Excel
 

MID Function in Excel

Jeevan A Y
Article byJeevan A Y
Madhuri Thakur
Reviewed byMadhuri Thakur

Updated May 3, 2023

MID Function in Excel

 

 

MID Function in Excel (Table of Contents)

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

  • MID in Excel
  • How to Use MID Function in Excel?

MID in Excel

The MID function works in the same way as the Right and Left functions do. It is up to us what portion of the middle text we want to extract. For example, if a cell contains FIRST, then using the Mid function there, we can select the character position from which we want to remove the text and the number of characters till we want. We will get IRS as output if we want from 2 positions to the next 3 characters.

For Example:

MID (“Bangalore is the Capital of Karnataka”, 18, 7) In this formula, the MID function will return from the 18th character it will return 7 characters, i.e. “Capital”.

The MID function is also available in VBA too. We will discuss that at the end of this article.

MID Formula in Excel:

Below is the MID Formula in Excel.

MID Formula in Excel

Explanation of MID Formula in Excel:

The MID formula has three compulsory parameters: i.e.text, start_num, num_chars.

  • text: From the text that you want to extract specified characters.
  • start_num: Starting position of the middle string.
  • [num_chars]: The number of characters you want to extract from the start-num.

Usually, the MID function in Excel is used alongside other text functions like SEARCH, REPLACE, LEN, FIND, LEFT, etc.

How to Use MID Function in Excel?

The MID function in Excel is very simple and easy to use. Both a spreadsheet function and a VBA function, the MID function has several uses. Let us understand the working of the MID function in Excel by some MID Formula examples.

You can download this MID Function Excel Template here – MID Function Excel Template

Example #1

In this MID Formula in Excel example, we are extracting the substring from the given text string by using the MID formula.

mid in excel Example 1-1

From the above table extract, characters from the 4th character extract are 6 characters.

mid in excel Example 1-2

So the result will be :

mid in excel Example 1-3

Example #2

Using the MID function, we can extract First Name & Last Names. Look at the below example where we have full names from A2 to A15.

mid in excel Example 2-1

From the above table, extract the first names for all the names.

mid in excel Example 2-2

Result is :

mid in excel Example 2-5

mid in excel Example 2-3

Part 1: This part determines the desired text that you want to extract from the characters.

Part 2: This determines the starting position of the character.

Part 3: The SEARCH function looks for the first space (““) in the text and determines the placement of the space.

mid in excel Example 2-4

Here the SEARCH formula returns 5 for the first name, which means space is the 5th character in the above text. So now the MID function extracts 5 characters starting from 1st.

So the result will be :

MID Example 2-6

NOTE: Space is also considered as one character.

Example #3

Below is the flight number list, and we need to extract the characters starting from Y till you find “ – “

MID Example 3-1

Look at the above example where the letters are in bold that we need to extract. It looks like one heck of a task. However, we can use MID alongside SEARCH or FIND functions. One common thing is all the bold letters start with Y, and it has 6 characters in total.

MID Example 3-2

A SEARCH function will determine the starting character to extract, and from the starting point, we need to extract 6 characters.

So the Result is :

MID Example 3-3

Example #4

Below is the list of companies alongside their registration number. The task is to extract only the registration number from the list.

MID Example 4-1

Closely look at the above list; one common thing before the registration number is the word Acct. This will be our key point to determine the starting point. In the previous example, we used SEARCH this time to look at the FIND function.

MID Example 4-2

MID Example 4-3

Part 1: This part determines the desired text that you want to extract from the characters.

Part 2: The FIND function first looks for the word “Acct” in the text, and from there, we need to add 5 more characters to the list, and that determines the starting position of the character.

We need to add 5 from Acct to the registration number; it is 5 characters, including space.

Part 3: Number of characters we need to extract.

So the result will be :

MID Example 4-4

Example #5

Now we will look at the combination of RIGHT, LEFT & MID functions in one example. We need to concatenate forward-slash (/) to separate Year, month & day.

Look at the below example where we have dates but no separators for a year, month, and day.

MID Example 5.1

Now, we need to insert separators for the year, month, and day.

MID Example 5.2

Firstly RIGHT function extracts 2 characters from the right and inserts one forward-slash (/), i.e. 25/

Now, we need to insert separators for the year, month, and day.

The second part is the MID function extracts 2 characters starting from the 5th character and inserts one forward-slash (/)

i.e. 25/10/

The final part is the LEFT function extracts 4 characters from the left-hand side and inserts one forward slash (/)

i.e. 25/10/2018

So the result will be :

MID Example 5.3

VBA Code to use MID Function

Like in Excel, we can use the MID function in VBA code also. The below code illustrates the usage of the MID function in VBA macros.

Sub MID_Function_Example
Dim Middle_String as string
Middle_String = Mid (“Excel can do wonders”, 14, 7)
Msgbox Middle_String
End Sub

If you run the above code message box will display wonders as your result.

Things to Remember

  • Number formatting is not part of a string and will not be extracted or counted.
  • It is designed to extract the characters from any side of a specified text.
  • If the user does not specify the last parameter, it will take 0 as default.
  • Num_chars must be greater than or equal to zero. If it is a negative number, it will throw the error as #VALUE.
  • In the case of complex data sets, you need to use other text functions like SEARCH and FIND Num_chars parameters.
  • Use the MID function to extract text from inside a text string based on location and length.
  • The MID function returns empty text if the start_num is greater than the length of a string.

Recommended Articles

This has been a guide to MID in Excel. Here we discuss the MID Formula in Excel and how to use the MID Function in Excel along with practical examples and downloadable Excel templates. You can also go through our other suggested articles –

  1. Uses of AND Function in Excel
  2. Best Examples of COLUMN Function in Excel
  3. LOOKUP Function in Excel
  4. Amazing uses of FV Function in Excel
  5. How to Use MID Function in VBA?
Primary Sidebar
Footer
Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA
Free Excel Course

Excel functions, formula, charts, formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

Download MID Function Excel Template

EDUCBA Login

Forgot Password?

EDUCBA

Download MID Function Excel Template

EDUCBA

डाउनलोड MID Function Excel Template

🚀 Limited Time Offer! - 🎁 ENROLL NOW