Formula

P

pnoel

I need to extract a number from a text string, then list
the number in a diffrent cell.

Please Help.

pnoel
 
R

Ron Rosenfeld

I need to extract a number from a text string, then list
the number in a diffrent cell.

Please Help.

pnoel

This VBA routine might work for you. It will extract all of the numeric
characters from a string:

====================
Function GetValue(str)
Dim N As Integer, i As String
i = ""
For N = 1 To Len(str)
If IsNumeric(Mid(str, N, 1)) Then
i = i & Mid(str, N, 1)
If Mid(str, N + 1, 1) = "." Then i = i & "."
End If
Next
If i = "" Then
GetValue = i
Exit Function
End If
GetValue = CDbl(i)
End Function
================

To enter it, <alt><F11> opens the VB Editor.

With your current project highlighted in the Project Explorer window,
Insert/Module and paste the above into the window that opens.

To use the routine, enter a formula of the type:

=GetValue(A1)

where your mixed string is stored in A1.


--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top