ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How can I seperate text and number from alphanumeric cell? (https://www.excelbanter.com/excel-worksheet-functions/166282-how-can-i-seperate-text-number-alphanumeric-cell.html)

Jennifer Medina

How can I seperate text and number from alphanumeric cell?
 
I have several addresses and I want to pull all of the numbers from the
address into a different column. The numbers are mixed in different spots and
the text to columns will not work for me. Example data:

123 S 5th Street

Need:

1235

Any help would be much appreciated!

Ron Rosenfeld

How can I seperate text and number from alphanumeric cell?
 
On Thu, 15 Nov 2007 13:10:14 -0800, Jennifer Medina <Jennifer
wrote:

I have several addresses and I want to pull all of the numbers from the
address into a different column. The numbers are mixed in different spots and
the text to columns will not work for me. Example data:

123 S 5th Street

Need:

1235

Any help would be much appreciated!


Here is a short VBA routine that should do what you want.

To enter this, <alt-F11 opens the VBEditor. Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

On the worksheet, enter =reNums(cell_ref) in some cell. It should return only
numbers from the string.

===============================
Option Explicit
Function reNums(str As String)
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
reNums = re.Replace(str, "")
End Function
=========================
--ron

Jennifer Medina[_2_]

How can I seperate text and number from alphanumeric cell?
 
Thank you so much for your help that was just what I needed.

"Ron Rosenfeld" wrote:

On Thu, 15 Nov 2007 13:10:14 -0800, Jennifer Medina <Jennifer
wrote:

I have several addresses and I want to pull all of the numbers from the
address into a different column. The numbers are mixed in different spots and
the text to columns will not work for me. Example data:

123 S 5th Street

Need:

1235

Any help would be much appreciated!


Here is a short VBA routine that should do what you want.

To enter this, <alt-F11 opens the VBEditor. Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

On the worksheet, enter =reNums(cell_ref) in some cell. It should return only
numbers from the string.

===============================
Option Explicit
Function reNums(str As String)
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
reNums = re.Replace(str, "")
End Function
=========================
--ron


Ron Rosenfeld

How can I seperate text and number from alphanumeric cell?
 
On Thu, 15 Nov 2007 13:38:09 -0800, Jennifer Medina
wrote:

Thank you so much for your help that was just what I needed.


You're welcome. Glad to help. Thanks for the feedback.
--ron


All times are GMT +1. The time now is 04:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com