Extract Text From Numbers&Text&Numbers Cell

Starrbuckk

New Member
Joined
Mar 24, 2016
Messages
19
Hi everyone,

I have data in "A" column as follow : 00230536UE037; 86473UE023; 004729831HO0471.
What i want to do is only to extract the Text from each one of the cells. Simple +Left/+Right will not work due to the variation of the number of characteres within each cell, and positioning of said text also.

Can anyone help?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi everyone,

I have data in "A" column as follow : 00230536UE037; 86473UE023; 004729831HO0471.
What i want to do is only to extract the Text from each one of the cells. Simple +Left/+Right will not work due to the variation of the number of characteres within each cell, and positioning of said text also.

Can anyone help?
Hi Starrbuckk, welcome to the boards.

I found the following User Defined Function (UDF) over at OzGrid that should do the trick for you.

- Press ALT+F11 to open the VBA Developer window
- Find the name of your Workbook in the Project Pane in the top left hand side of the VBA Developer window
- Right-click on ThisWorkbook and select Insert->Module
- In the new window that opens simply copy and paste in the following code:

Code:
Function StripNumber(stdText As String)
    Dim str As String, i As Integer
     'strips the number from a longer text string
    stdText = Trim(stdText)
    For i = 1 To Len(stdText)
        If Not IsNumeric(Mid(stdText, i, 1)) Then
            str = str & Mid(stdText, i, 1)
        End If
    Next i
    StripNumber = str ' * 1     
End Function

- Now go back to your actual workbook and (assuming your data starts in A1) put the following in cell B1 and press enter:

=StripNumber(A1)

You can drag-fill this down the length of your column.
 
Upvote 0
- Press ALT+F11 to open the VBA Developer window
- Find the name of your Workbook in the Project Pane in the top left hand side of the VBA Developer window
- Right-click on ThisWorkbook and select Insert->Module
- In the new window that opens simply copy and paste in the following code:

Code:
Function StripNumber(stdText As String)
    Dim str As String, i As Integer
     'strips the number from a longer text string
    stdText = Trim(stdText)
    For i = 1 To Len(stdText)
        If Not IsNumeric(Mid(stdText, i, 1)) Then
            str = str & Mid(stdText, i, 1)
        End If
    Next i
    StripNumber = str ' * 1     
End Function

How would i go about saving the Custom Function for Future use?
 
Upvote 0
Glad to hear it did the trick.

With regards to saving it for future use I assume you mean in workbooks other than the current one?

- From the VBA Developer window, double-click on Module1.
- Just below the Project Pane on the left you should see the Properties pane.
- Find where it says (Name) Module1, click in the box and change the name from Module1 to something you will easily remember and press enter.
- Go back up the Project Pane, right-click on whatever you have renamed Module1 as and select Export File.
- A "Save As" dialogue box will come up allowing you to save the module out to a place of your choosing (make sure it is somewhere you will be able to find it again afterwards)
- In any new workbooks, go to the VBA Developer window, right-click on ThisWorkbook and select Import
- Browse to where you exported the module and select it to add it to your new workbook.
 
Upvote 0
an alternative

Code:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,"")
 
Upvote 0
an alternative

Code:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,"")
Thank you, it works aswell =)
 
Upvote 0

Forum statistics

Threads
1,216,109
Messages
6,128,883
Members
449,477
Latest member
panjongshing

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top