Seperate numbers from letters
On Wed, 17 Dec 2003 08:33:08 -0800, "Jamal"
wrote:
I have a column within a list which is made up of numbers
and letters. Most of the time they are in blocks and I can
sepearte them using a custom function. However,
occassionally numbers are mixed with letters
e.g "And24this253". How can I seperate the numbers out of
this but keep the same order as they appear?
Thank you so much for your help.
Well, since this is a programming group, here are two UDF's to accomplish this:
================
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
'-----------------------
Function GetLtrs(str) As String
GetLtrs = ""
Dim N As Integer
For N = 1 To Len(str)
If Not (IsNumeric(Mid(str, N, 1))) Then GetLtrs = GetLtrs & Mid(str, N,
1)
Next
End Function
=============================
--ron
|