Future-Proof Your Career, Master Data Skills + AI

Blog

Future-Proof Your Career, Master Data Skills + AI

Blog

How to Remove Numbers in Excel From the Left: It’s Easy!

by | 11:22 pm EDT | May 11, 2023 | Excel

There are times when you work with data that is not formatted in the way you need. For example, you may have a mix of numbers and text in a cell, and you need to clean up this data.

There are several techniques to remove numbers in Excel from the left of the text. Some methods work when the data has a consistent pattern. VBA or more complex formulas work on less structured data.

This article demonstrates seven methods to delete numbers on the left of text data. By the end, you will have a comprehensive understanding of the different techniques and when to use them.

Let’s go!

How to Use Flash Fill to Remove Numbers in Excel From the Left

Flash Fill is an Excel feature that can automatically fill in patterns for you. It’s a quick and easy way to remove numbers from the left side of cells.

This method may not always work perfectly, but it can be helpful for simple cases. Follow these steps to use Flash Fill:

  1. In an empty column adjacent to your data, type the desired result without the numbers (e.g., if “1234apple” is in cell A1, type “apple” in cell B1).

  2. Select the cell with the new data (B1 in our example) and click the Data tab on the ribbon.

  3. Click the Flash Fill button in the Data Tools section.

  4. Excel will automatically apply the pattern to remove numbers from the left side of the adjacent cells.

This is the location of the Flash Fill button in the Data tab.

How to remove numbers in Excel from the left

If you prefer to use shortcuts, press CTRL + E on Windows or CMD + E on a Mac.

Flash Fill is a handy feature, but as with most things in Excel, there are multiple ways to accomplish the same task.

In the next section, we take a look at how you can do the same thing using the “Text to Columns” feature.

How to Use the Text to Columns Feature to Remove Numbers

You can use the “Text to Columns” feature in Excel to separate numbers from the left of a cell. However, this method assumes that there’s a consistent pattern or delimiter between the numbers and the text in the cell.

Let’s work with a set of data that uses a dash to separate numbers from letters like this:

  • 1234-apple

  • 4321-orange

  • 9876-pear

This is the before-and-after we want to achieve:

Text to Columns before-and-after display in Excel

Here’s a step-by-step guide with this sample data set:

  1. Select column A.

  2. Go to the Data tab and click on the Text to Columns wizard.

  3. Choose the Delimited option and click Next.

  4. Uncheck all delimiters (the tab may be applied by default).

  5. Check the Other delimiter and type “-“ into the input box.

  6. Select the appropriate delimiter (space, comma, etc.).

  7. Click Next and Finish.

The data will now be separated into two columns. The removed characters are in the first column while the rest of the text is in the second column. This picture shows how to set the delimiter:

Text to column using the dash delimiter in Excel

Next, let’s take a look at five text functions for removing numbers in Excel.

5 Text Functions to Remove Numbers in Excel From the Left

If you know how many characters make up the digits, then you can use a text function to remove them.

Suppose cell A1 contains the string “1234apple”. The first four characters are numbers that we want to remove.

There are several functions that can be used on their own or combined for removing characters that are numeric values.

1. MID Function

You can use the MID function to extract the part of the string that starts from the 5th character.

The MID function extracts a specific section of a text string, given the starting position and the number of characters to extract. The syntax for the MID function is:

MID(text, start_num, num_chars)

  • text: The text string containing the characters you want to extract.

  • start_num: The position of the first character you want to extract.

  • num_chars: The number of characters to extract from the text string.

To remove the numbers on the left, follow these steps:

  1. select cell B2 to contain the function and results.

  2. Type the formula: MID(A1, 5, 7)

The above formula will remove characters from the 5th slot in the string.

2. Combine with the LEN Function

One drawback with this method is that your text string may not always be the same length.

You can use the LEN function to calculate the length dynamically. This function returns the length of a text string.

You can modify the formula to replace the third parameter with the LEN function like this:

=MID(A1, 5, LEN(A1)-4)

You can copy the formula down by using the fill handle. This picture shows the above formula in use:

formula using mid and len function

3. Combining LEFT and SUBSTITUTE Functions

The LEFT function returns the leftmost characters from a text string. For example, LEFT(“1234apple”, 4) would return the value “1234”.

This is useful when you want to extract the numbers. But what if you want to remove them?

You can combine LEFT with the SUBSTITUTE function to replace the number with an empty string. This is the format for our example:

=SUBSTITUTE(A1, LEFT(A1, 4), “”)

formula using left and substitute function

4. Using the RIGHT and LEN Function

The RIGHT function returns the rightmost characters from a text string. The syntax for the RIGHT function is:

RIGHT(text, [num_chars])

  • text: The text string containing the characters you want to extract.

  • num_chars: (Optional) The number of characters to extract from the right side of the text string. If omitted, it defaults to 1.

For example, RIGHT(“1234apple”, 5) would return the value “apple”.

You can also combine the RIGHT and LEN functions to avoid hard coding the number of alpha characters. This is assuming that you know the number of numeric characters.

The format for our example is: =RIGHT(A1, LEN(A1)-4)

5. Using the REPLACE Function

The REPLACE function can be used to replace a specific number of characters from the left in a cell. This is the syntax:

REPLACE(old_text, start_num, num_chars, new_text)

  • old_text: the original text string that you want to modify.

  • start_num: the position in the old_text where you want to start replacing characters.

  • num_chars: the number of characters in the old_text that you want to replace.

  • new_text: the text string you want to replace the specified characters with.

The following formula is for our sample data:

=REPLACE(A1, 1, 4, “”)

Formula with replace function in Excel

And that’s the last of our five text functions for removing characters from the left in Excel.

In most cases, the seven methods we’ve covered so far should be enough, but if you want more power, Power Query is the answer, and that’s what we’ll talk about in the next section!

How to Use Power Query to Remove Numbers From Left

Power Query is a powerful data transformation tool available in Excel. The method shown in this section assumes that there is a delimiter between the numbers and the text in the cell.

The first step is to transform the target data into a table:

  1. Go to the Data tab.

  2. Select the cell range.

  3. Choose “From Table/Range” from the Get Data section in the ribbon.

Choose get data from table/range under data tab in Excel

When the Power Query Editor opens, follow these steps:

  1. Select the target column(s).

  2. Go to the “Transform” tab

  3. Click on “Extract” in the ribbon, and choose “Text After Delimiter.”

  4. In the “Text After Delimiter” dialog box, enter a dash (-).

  5. Click “OK” to accept the details.

The transformed column will now have the numbers removed from the left of the text.

Click “Close & Load” to load the transformed data back into your worksheet.

If you’re new to this data tool, check out our tutorial on how to use Power Query in Excel.

If you want to dive deeper into using tables in Power Query, this video walks through some more complex examples:

3 Advanced Techniques Regardless of How Many Characters

The main drawback of the methods so far is that the numbers in all the cells must follow the same pattern or be a specific number of characters.

What if you want to delete characters without a clear pattern in the original data? The techniques in this section are for intermediate Excel users.

1. Combine a Helper Column With a Formula to Remove Characters From Left Of Cells

You can combine functions with helper columns when you don’t know the total length of the numbers. This method requires a two-step process:

  • use a formula to create a temporary modified version of the original text

  • use another formula to remove the numbers based on the modified text.

The first step is to use the following formula to replace all the numbers with a specific character (e.g., “|”):

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

The second step is to use the following formula in another helper column (e.g. column C):

=TRIM(RIGHT(SUBSTITUTE(B1, “|”, REPT(” “, LEN(B1))), LEN(B1)))

This is the before-and-after with the formulas in column B and C:

helper columns in B and C

When you start combining functions like this, you can run into issues with choosing the wrong options in your formulas. Our article on how to find circular references in Excel will help you troubleshoot a common error.

You may also want to share a spreadsheet that contains helper columns. It’s important that your colleagues don’t delete or amend the formulas in the intermediate results. Our article on ways to lock columns in Excel will help you to produce the functionality.

2. Create a VBA Macro to Remove Numbers

VBA is a versatile scripting language that lets you automate tasks and create custom solutions within Excel.

For example, you can write a macro that removes numbers from the left of all cells in a specific column or range.

To do so, follow these steps:

  1. Press ALT + F11 to open the VBA editor.

  2. Click Insert > Module to create a new module.

  3. Copy and paste the following code to remove only numbers from the left of column A:

Sub RemoveLeftNumbers()
    Dim ws As Worksheet, cell As Range, i As Integer
    
    ' Set the active worksheet as the target worksheet
    Set ws = ActiveSheet

    ' Loop through all the cells in column A
    For Each cell In ws.Range("A1:A" & ws.Cells(ws.Rows.Count, 1).End(xlUp).Row)
        ' Remove numbers from the left of each cell
        For i = 1 To Len(cell.Value)
            If Not IsNumeric(Mid(cell.Value, i, 1)) Then
                Exit For
            End If
        Next i
        cell.Value = Mid(cell.Value, i)
    Next cell
End Sub

The last step is to run the macro. Click the green triangle or the “run” menu item.

vba macro to remove characters

3. Create a User-Defined Function

You can also create a user-defined function with VBA that you can utilize in your formulas.

To do so, follow these steps:

  1. Press ALT + F11 to open the VBA editor.

  2. Click Insert > Module to create a new module.

  3. Copy and paste the following code:

Public Function RemoveNumbersFromLeft (text As String) As String
    Dim i As Integer
    For i = 1 To Len(text)
        If Not IsNumeric(Mid(text, i, 1)) Then
            Exit For
        End If
    Next i
    RemoveNumbersFromLeft = Mid(text, i)
End Function

Now, return to your Excel sheet and use the public function in a formula.

For example, this formula works by accepting the A1 cell:

=RemoveNumbersFromLeft(A1)

Final Thoughts

In this article, we have explored multiple methods to remove numbers from the left side of text strings in Excel. Each technique has its own advantages and limitations.

No single method is perfect for every situation, but there is sure to be an approach that best suits your needs. With practice, you will become proficient in applying these techniques to handle any data formatting challenge that comes your way.

So there you have it, the ins and outs of removing unwanted digits from the left in Excel. It might look a bit tricky at first, but with the right techniques, you’ll be bossing it in no time! Happy number-crunching!

Related Posts