ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to Extract Text from a Cell in Microsoft Excel

Updated on January 23, 2015

Useful Excel Functions for Text Extraction

There are 5 main functions I find particularly useful when manipulating text in Microsoft Excel. You may already be familiar with these functions, but when used creatively, they can accomplish pretty much anything you need to do regarding text manipulation in Excel.

1. =len(text) - This length function calculates the number of characters in a text string. Useful in combination with other functions to extract the text you want.

2. =left(text,[num_chars]) - This function returns a text string of a specified length (input as [num_chars]), starting with the leftmost character in the selected text string.

3. =right(text,[num_chars]) - This function returns a text string of a specified length (input as [num_chars]), starting with the rightmost character in the selected text string.

4. =mid(text, start_num, num_chars) - This function returns a text string of a specified length (input as num_chars), starting with a specific character number (input as start_num) in the selected text string.

5. =find(find_text, within_text, [start_num]) - This function searches a text string (within_text) for a character or string (find_text) and returns the character number at which the searched character is found.

Hopefully you can start to see how powerful these 5 functions can be when used in combination.

Example 1: Extracting First 3 (or Last 3) Characters from a String

Let's start out with a basic example. Say you want to take just the first three characters from a text field. The LEFT function can do that. See the screenshots to the right. The formula has two inputs, first the text string you wish to extract from (A2 in this case), and second the number of characters you wish to extract (3).

The same methodology can be applied with the RIGHT function to extract the last three characters (or digits) from a string.

You can do this to return any number of characters from the string. To return only the first (or last) two characters, replace the number 3 with the number 2 in the [num_chars] argument of the LEFT or RIGHT function.

Example 2: Extracting Text from the Middle of a String

Pulling text from the middle of a string can be a little bit trickier than starting from the left or the right, but as long as you know the starting point (character #) within the string and the length of the segment you want to extract, the MID function will do the trick.

NOTE: If the starting point is not always the same character number, see Example 5 below

Here you will need to input two different numbers as arguments to the MID function. The first will be the starting point of the string you wish to extract, 4 in the example to the right. The second will be the length of the segment you wish to extract. In the example to the right, the formula is written as =MID(A2,4,3). This will return the 4th, 5th, and 6th characters from the string. These numbers can be changed to achieve the result you are looking for.

Example 3: Extracting a Variable Number of Characters from the Beginning of a String

This is where things start to get exciting. Let's say you have a list of names in the format Last Name, First Name. You want to extract the Last Name from the string. You know you want to use the LEFT function, but not all the last names are the same length. This is where the FIND function comes in handy. Because there is a comma separating the Last Name from the First Name in our data set, we can use the FIND function to return the character number of the comma and only return the characters that come before. See the example to the right.

Note how these two formulas are used in combination to achieve the desired result. Instead of specifying a fixed number of characters to return, we call another function to tell us where the comma is. The FIND function requires two inputs. First, the text you are searching for in quotation marks ("," in this scenario). Second, the text string you want to search in (A2). This returns the character number the first comma is found at. If you have more than one comma in the searched text this formula will return only the location of the first. We then have to subtract one from the result, as we don't want the comma to be included in the text string returned.

This can be used in any situation when you have a dividing character such as the comma in our example between the text you want to extract and the rest of the string. Ideally, the dividing character would only occur once in the string to eliminate the possibility of the FIND formula turning up the wrong result.

Example 4: Extracting a Variable Number of Characters from the End of a String

This is the same situation as above, but now we want to extract what comes after the dividing character. Continuing our example, now we want to extract the First Name from the string. We can do this using the RIGHT function, but now we have to determine the length of the first name in order to cut the string off at the right point.

In the example to the right, we now are using three functions together. We are using the LEN function to return the total number of characters in the string. If we again use the FIND function to return the location of the comma, we can subtract that from the total number of characters to return the number of characters after the comma. Because there is a space between the comma and the first letter of the first name, we again subtract one from the number returned.

Example 5: Extracting Text from a Variable Place within the Middle of a String

The last example I will give in this article is to be used when there is a string of defined length within the larger string that needs to be extracted, but the starting point is not always the same. In order for this to work, there has to be a characteristic that all the strings being extracted share. In the example to the right, that characteristic is the letters YR at the end.

Here, we use the MID function to extract the string we are looking for, but the starting point is defined using the FIND function. We search for "YR" and take the starting character number, then subtract one to get to the character before. The string we are looking for is three letters long, so the last input to the function is the number 3. This is just one example, and the formula can be manipulated a number of ways to fit the specific application.

As you can see, these five functions can become very powerful tools when used creatively and in combination. There are many other applications I have not outlined above, so feel free to post your favorites in the comments section below. Please also post any challenges regarding text extraction and manipulation in Excel that you haven't been able to solve and I will do my best to help out.

Were you able to solve your problem after reading this article?

See results

How Would You Rate Your Excel Proficiency?

See results


    0 of 8192 characters used
    Post Comment
    • TTGReviews profile image


      4 years ago

      I will keep this in mind. I have wondered how to do this in the past.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)