separate the numerical values in a string

  • Thread starter Thread starter nebrass
  • Start date Start date
N

nebrass

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,
 
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
 
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
 
Back
Top