Open In App

How to Extract Text Only from Alphanumeric String in Excel?

Last Updated: 06 Dec, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

In the vast landscape of Excel spreadsheets, managing data efficiently is crucial for streamlined analysis and reporting. Often, one encounters the challenge of dealing with cells containing a mix of letters and numbers, commonly known as alphanumeric strings. Extracting only the text component from such strings becomes essential for various data manipulation tasks. In this article, we will explore practical methods to effortlessly extract text-only portions from alphanumeric strings in Excel. Whether you’re a seasoned Excel user or just embarking on your spreadsheet journey, mastering these techniques will empower you to wrangle your data with precision and ease. Join us as we unravel the secrets to extracting meaningful text from the alphanumeric complexity, making your Excel experience more efficient and tailored to your specific needs.

What is a Substring in Excel?

To put it simply, it’s a text entry. In this article, we will be using various approaches to extract text from Alphanumeric strings.

How to Extract Substring of a Certain Length

Three distinct functions are available in Microsoft Excel to extract text from a cell that is a certain length. Use one of these formulas based on where you want to begin the extraction.

  • LEFT function – to take the leftmost substring and extract it
  • RIGHT function – to take the rightmost substring and extract it
  • MID function – to begin extracting a substring from the centre of a text string at the specified position

Extract Substring from Start of String (LEFT)

Using the Excel LEFT function, we can extract text from the left of a string.

Syntax 

=LEFT(text, [num_chars])

Here, Text is the cell’s address where the source string is located and The amount of characters you want to extract is num_chars.

E.g. To select the first 5 characters from the start of the string, use:

=LEFT(A2,5)

LEFT formula to extract a substring

 

Get Substring from End of String (RIGHT)

Use the Excel RIGHT function to extract a substring from the end of a string

Syntax

=RIGHT(text, [num_chars])

E.g. To select the last 5 characters from the end of the string, use:

=RIGHT(A2,5)

RIGHT formula to extract a substring

 

Extract text from Middle of String (MID)

MID is the function to use if you want to extract a substring that begins in the centre of a string at the place you provide.

Syntax 

=MID(text, start_num, num_chars)

Here, apart from the aforementioned elements, start_num indicates the starting point 

E.g. To select 2 characters from the middle of the string starting at the 5th character, use:

=MID(A2,5,2)

MID formula to extract a substring

Most often, we receive “ID fields” as alphanumeric strings. Suppose we have to extract only text from “ID fields” for further process.  

Let’s explore different approaches to extract text from an alphanumeric string in Excel.

Approach 1.  Using Excel Formula

The above-discussed problem statement can be resolved using inbuilt Excel formulas, as discussed below:

Syntax:

=SUBSTITUTE (text, old_text, new_text, [instance_num])

Where,

  • text: It is the input cell (text).  
  • old_text: It is the text to find.
  • new_text: It is the text to replace.

Step 1. Open Excel.

Step 2. Type any alphanumeric string in cell “B5” (e.g. geeksId345768).

Step 3. Write below formula in cell “C5” (we used nested substitute function to replace numbers 0 to 9)

= SUBSTITUTE(SUBSTITUTE( SUBSTITUTE( SUBSTITUTE( SUBSTITUTE(SUBSTITUTE( SUBSTITUTE( SUBSTITUTE( SUBSTITUTE( SUBSTITUTE(B5,”0″,””),”1″,””),”2″,””), “3”,””),”4″,””),”5″,””), “6”,””),”7″,””),”8″,””),”9″,””)

extracted text from an alphanumeric string

Approach 2. Excel VBA User-Defined Function

In Excel VBA we can define functions to resolve the problem statement. An implementation is given below for the same.

Step 1. Open Excel.

Step 2. Type any alphanumeric string in cell “B5” (e.g. geeksId345768).

alphanumeric string in cell

Step 3. Write below VBA code in the module:

Function onlyText(rg As Range) As String

Dim ipVal As String

Dim opValue As String

  • Initialize variable

ipVal = rg.Value

  • Iterate the input string

For i = 1 To Len(ipVal)

  •  Check the character is Numeric or not

   If Not IsNumeric(Mid(ipVal, i, 1)) Then

       opValue = opValue & Mid(ipVal, i, 1)

   End If

Next

  • Return output

onlyText = opValue

End Function

Step 4. Save your Excel file as “Excel Macro-Enabled Workbook”  [*.xlsm]  

saving the file

Step 5. Type the function name “=onlyText(B5)” in cell “C5”.  

Macro remove all numeric character from cell “B5” and return to cell “C5”.

extOnlyAlpha005

Conclusion

Simply put, dealing with a mix of letters and numbers in Excel doesn’t have to be a headache. This article has some neat tricks to help you pull out only the text you want from those alphanumeric jumbles. Whether you’re a pro at spreadsheets or just getting started, these methods using Excel functions or combining them will tidy up your data, making it more sensible and user-friendly. Think of Excel like a toolbox, and by adding these text extraction skills, you’re giving yourself an edge in handling all kinds of alphanumeric puzzles. So, give it a shot, try out these techniques, and watch how they can make your Excel adventures smoother and more productive!



News
Improve
Discuss
Do you want to advertise with us?Click here to know more

How to Extract the last N Words from Text String in Excel

Excel is a tool for storing and managing a large amount of data. Data is entered in a rectangular block, which we called a cell. This tool can be used to perform different tasks like creating graphs and analyzing trends, to get insights from the data. It is primarily used for financial data analysis by accounting professionals. Let's learn how to extract the last N-word in Excel.  For example, we have a string "Welcome to GeeksforGeeks platform" and we need to extract the last 2 words from the string, then the output should be "GeeksforGeeks Platform". How to Extract the Last N-Word in ExcelFor demonstration, we will use the following string "Hello Geeks, Welcome to the GeeksforGeeks Platform". As an example, We will extract the last 5 words of the given string. Follow the below steps, Step 1: Count the number of spaces in the string. The formula for counting spaces,LEN(cell_name)-LEN(SUBSTITUTE(cell_name," ","")) Example:OutputStep 2: Replace the fifth space from the last with any special character like @. Formula is,SUBSTITUTE(cell_name," ","@",(LEN(cell_name)-LEN(SUBSTITUTE(cell_name," ",""))-5+1)). Example:OutputStep 3: Get the location of the special character. Formula is,LEN(
Read More

How to Extract Text before @ Sign from an Email Address in Excel?

article_img
You got a dataset and you want to extract the name part of the email address. This task can be done with a text to column and formula that uses the LEFT and FIND functions. Using LEFT and FIND functionsThe LEFT function: The LEFT function returns a given text from the left of our text string based on the number of characters specified. Syntax: LEFT(text, [num_chars]) Parameters: Text: The text we want to extract from. Num_chars (Optional): The number of characters you want to extract. Default num_chars is 1 and the number must be a positive number that is greater than zero. Example: Step 1: Format your data. Now if you want to get the first geeks from geeksforgeeks in B2. Let us follow the next step. Step 2: We will enter =LEFT(B2,5) in the B3 cell. Here we want Excel to extract the first 5 characters from the left side of our text in B2. This will return Geeks. Let us move to the FIND function. The FIND function: The FIND function returns the position of a given text within a text. Syntax: FIND(find_text, within_text, [start_num]) Parameters: Find_text: The text we want to find. Within_text: The text containing our find_text.Start_num (Optional): The starting position of our f
Read More

How to Extract Unique Items From a List in Excel

article_img
Microsoft Excel is a powerful tool widely used for data manipulation and analysis. Extracting unique items from a list is a common task in Excel that involves identifying and removing duplicates, leading to cleaner and more accurate data. We often need to report Unique customers/products/items from a given data for data analysis. In this article, we explore different approaches in Excel to list the unique items from a column. This lesson explains various techniques for pulling a distinct or unique list from an Excel column. This article also describes how to eliminate duplicates from a range. One of the most frequent data-processing tasks in Excel is this one. Why Extracting Unique Items MattersExtracting unique items from a list is crucial for several reasons: Data AccuracyRemoving duplicate entries ensures accurate analysis and prevents overcounting and undercounting your data. Data VisualizationUnique items provide a clearer and more concise dataset, making it easier to create meaningful visualizations. Data CleaningExtracting unique items helps clean up data, leading to more reliable insights and decision-making. ScenarioSay you have a list of the names of the Customers. A few
Read More

How to Extract the Last Word From a Cell in Excel

article_img
Explore how to extract the last word from a cell in Excel. Whether you’re working with text data, names, or any other content, knowing this technique can be incredibly useful. In this article, we explain how to extract the last word from a text in a cell using the Excel function.  Extracting words from a text is an important task in text processing. Functions to Extract the Last Word from a Cell in Excel Eg.  Suppose we have a data file with a field called “Product_Category”, which combines both product name and their respective category name with space as below.  Assume that the last word from the “Product_Category” field is a category.  We have to extract categories from the given data in column B for further analysis. Sample Data: We use the below list of 4 Excel user-defined functions to extract the last word. The REPT() Function Syntax: REPT(text, number)Where, text – character to repeatnumber – number of times to repeat the characterEg: REPT(“*“,10) – returns ********** The SUBSTITUTE() Function Syntax: SUBSTITUTE( text, old_text, new_text, [instance_number] )Where, text – the original text old_text – text need to replacenew_text –text replace with old text[instance_number] –
Read More

How to Find the Longest or Shortest Text String in a Column in Excel?

article_img
In this article, we will see how to find the longest or shortest text string in a column in Excel? Usually, for finding the longest or shortest string we can visit the all string in columns one by one and compare them to get results. This seems to work when you have less amount of data in an excel sheet. This is not a particle with a large dataset in Excel. Let's see how you can find the longest or shortest string in the column by using just one single line of formula in Excel. Longest Text String in a Column: We will use the below formula to get the longest text string in a column in an excel file. Syntax: =INDEX(range,MATCH(MAX(LEN(range)),LEN(range),0) Parameters: INDEX: Returns the value of the given position in the columnMATCH: Locate the position of a lookup value in a columnMAX: Returns the largest valueLEN: Returns the length of the given stringrange: Input range of columnExplanation of Formula: Let's start with the inner parenthesis value. LEN(range) will return the array of the length of the cell that comes under the input range. Now MAX will return the maximum numeric value it that is the maximum length from the given array. Now this two are passed to MATCH. It will retu
Read More

How To Convert Date To Number String Or Text Format In Excel?

article_img
Excel's built-in date system by default supports dates between January 1, 1900, and December 31, 9999. In this range, the numbers start at 1 and increase by 1 each time. In addition to text and numeric data types, Excel also allows dates that are internally stored as serial numbers. In Excel, the date format is typically recognized by default. However, Excel also allows you to input date format by choosing the cell and pressing (Ctrl+;). Methods to Convert Date to Number StringDATEVALUE Function Syntax: =DATEVALUE (date_text) Where date_text is the only argument DATEVALUE FunctionCell FormattingStep 1: Once the cell with the value has been chosen, click the home tab and choose the NUMBER or TEXT option. Step 2: The cell format then changes into the original serial number internally stored by Excel. Note: The first serial number stored by excel is of date 01/01/1900. Methods to Convert Date to TextTEXT Function It is used to convert a date into a specified text format. Syntax: =TEXT(value, format_text) For today’s date: =TEXT(TODAY(), format_text) Where value: The value that needs to be converted. This could be a numeric cell reference or value, or a numeric value returned by
Read More

Editing Excel Macros in Excel

article_img
Excel Macro is a set of actions that can be recorded, saved, used multiple times. This feature saves us a lot of time when dealing with repetitive tasks and huge data sets. We can always make changes to an existing Macro in Excel. There are two ways to record and run macros: Excel Commands Excel Visual Basic for Applications(VBA).1. Copying a Macro Code We can reuse the existing macro code while creating new Macros. For example, if you have existing macros created using the record function, we can reuse the code to write new macros. To open the code follow the below steps: Select Tools --> Macros --> Visual Basic Editor. Copy code from the existing macros(use Command + C) and paste(use Command + V) in the new macro2. Renaming a Macro Follow the below steps to rename a Macro in Excel: Select Tools --> Macros --> Visual Basic Editor. Select name on the left plane.Edit the name.3. Deleting a Macro Follow the below steps to delete a macro in Excel: Select Tools --> Macros --> Macros... Select the macro to be deleted. Click on the minus(-) symbol at the bottom.Select yes to delete the macro.
Read More

Best Microsoft Excel High-Paying Jobs with Excel Skills in 2024

article_img
Are you ready to unlock a world of opportunities with Microsoft Excel? In today’s data-driven job market, mastering Excel is essential for launching a successful career, whether you're a fresher or an experienced professional. In this article, we will cover the high-paying Excel jobs available in 2024, including crucial roles like data analyst, business analyst, and many more. We'll explore the qualifications needed for these positions, along with salary estimations to help you understand your earning potential. Whether you’re looking for Excel jobs for freshers or seasoned professionals, we’ll also dive into options for Excel freelancing jobs and work-from-home jobs in Excel. Equip yourself with the knowledge to excel in your career and take the first step toward a lucrative future!Best Microsoft Excel High-Paying Jobs with Excel Skills in 2024Table of ContentWhy choose a career in ExcelWhy Excel Skills Are Essential for Your CareerEssential Excel Skills Required to Boost Your Resume Best Microsoft Excel High-Paying JobsFinancial AnalystsData AnalystAdministrative Assistant Accountants Project ManagersManagement ConsultantRetail Store ManagersBusiness Analyst Market Research A
Read More

Excel VLOOKUP Function - Excel Guide for Beginners

article_img
How to do Vlookup in Excel - Quick StepsPrepare Your DataEnter the VLOOKUP Formula >>Press EnterUse a Cell Reference for Flexibility Copy the Formula for Multiple RowsThe VLOOKUP function is one of the most widely used tools in Excel for looking up and retrieving data from a table. Whether you’re working with a single sheet or multiple workbooks, VLOOKUP allows you to search for a value in one column and return a related value from another. If you're new to Excel or still getting the hang of formulas, this guide is for you. We will cover everything from the basics of how VLOOKUP works to practical examples that show how to search data across sheets, troubleshoot common issues, and master the VLOOKUP formula for any task.Excel VLOOKUP FunctionWhat is the VLOOKUP Function in ExcelThe term VLOOKUP stands for Vertical Lookup. It is designed to search for a specific value in the first column of a table (lookup column) and retrieve corresponding data from a different column in the same row.Syntax of VLOOKUP FormulaVLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])Arguments:1. lookup_value: The value you want to search for (e.g., a specific ID, name, or product code).
Read More

AI in Excel: Top 20 Excel AI Tools in 2025 (Free/Paid)

article_img
The integration of AI in Excel is transforming the way professionals manage, analyze, and visualize data. Whether you're handling large datasets, performing financial analysis, or automating repetitive tasks, AI-powered tools can significantly improve efficiency and accuracy. In 2025, advanced Excel AI tools are making complex tasks easier by offering features like data cleaning, predictive analytics, smart automation, and AI-driven insights.In this guide, we’ve gathered a list of the top 20 Excel AI tools for 2025 that are reshaping how users interact with Excel.Table of ContentBest AI Tool in Excel: Top Picks for 2025Top 10 Free Excel AI Tools in 2025Top 10 Excel AI ToolsAI in Excel: OverviewIn Excel, an AI tool (Artificial Intelligence tool) refers to an add-in or extension that leverages artificial intelligence to enhance your spreadsheet experience. These tools can automate tasks, improve data analysis, and generally make you more productive.Excel has always been a powerful tool for data analysis, but with the integration of AI tools, it has transformed into a smarter, more intuitive platform.Best AI Tool in Excel: Top Picks for 2025Explore the below AI tools designed for auto
Read More
three90RightbarBannerImg