View Single Post
  #2  
Old July 13th, 2004, 07:39 PM
Ron Rosenfeld
external usenet poster
 
Posts: n/a
Default finding a value in a string

On Tue, 13 Jul 2004 13:10:24 -0500, icestationzbra
wrote:

would anyone be able to give me one formula that could pick that number
for me from the string?


It's not clear from your posting what kind of output you want.

But here is a UDF (User defined function) that extracts all of the digits as a
number.

If you have a specific output in mind, please post it.

=================================
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)
End If
Next
If i = "" Then
GetValue = i
Exit Function
End If
GetValue = CDbl(i)
End Function
========================

To enter this, alt-F11 opens the VB Editor.

Ensure your project is highlighted in the Project Explorer, then Insert/Module
and paste the code into the window that opens.

Use it in your worksheet like any function. e.g. =getvalue(A1)


--ron