ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   separate the numerical values in a string (https://www.excelbanter.com/excel-programming/357080-separate-numerical-values-string.html)

nebrass

separate the numerical values in a string
 

Hi,

I have an excel worksheet that has a column that contains values that
look like this "BD345". I need to extract the numbers by using a macro
since I have about 15000 entries. For example in a cell where the value
is BD345 I want to activate the macro and then get the 345 in the same
cell or in the next one it doesn't mattter as where as long as I get
the numerical value.

I appreciate any help I can get on this. Thank you in advance.

Kind Regards,


--
nebrass
------------------------------------------------------------------------
nebrass's Profile: http://www.excelforum.com/member.php...o&userid=32802
View this thread: http://www.excelforum.com/showthread...hreadid=526220


rbanks[_20_]

separate the numerical values in a string
 

Hello I think this link will help - in it is a fantastic tool.
Among many other useful tools, there is a function that removes all
non-numeric characters from a cell or range of cells.


the link - http://www.asap-utilities.com/ - it is free


--
rbanks
------------------------------------------------------------------------
rbanks's Profile: http://www.excelforum.com/member.php...fo&userid=2944
View this thread: http://www.excelforum.com/showthread...hreadid=526220


Ron Rosenfeld

separate the numerical values in a string
 
On Fri, 24 Mar 2006 15:00:41 -0600, nebrass
wrote:


Hi,

I have an excel worksheet that has a column that contains values that
look like this "BD345". I need to extract the numbers by using a macro
since I have about 15000 entries. For example in a cell where the value
is BD345 I want to activate the macro and then get the 345 in the same
cell or in the next one it doesn't mattter as where as long as I get
the numerical value.

I appreciate any help I can get on this. Thank you in advance.

Kind Regards,



Here's one way to do it with a macro:

==========================
Sub ExtractDigits()
Dim c As Range
Dim n As String
Dim i As Long

For Each c In Selection
n = ""
For i = 1 To Len(c.Text)
If Mid(c.Text, i, 1) Like "#" Then
n = n & Mid(c.Text, i, 1)
End If
Next i
c.Value = Val(n)
Next c

End Sub
=============================
--ron


All times are GMT +1. The time now is 11:02 PM.

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