Splitting text
On Wed, 12 Nov 2008 08:10:00 -0800, JLatham <HelpFrom @
Jlathamsite.com.(removethis) wrote:
Function GetDigits(whatCell As Range) As String
Dim srcString As String
Dim LC As Integer
GetDigits = ""
srcString = whatCell.Value
For LC = 1 To Len(srcString)
If Mid(srcString, LC, 1) = "0" And Mid(srcString, LC, 1) <= "9" Then
GetDigits = GetDigits & Mid(srcString, LC, 1)
Else
'must have hit non-digit, quit
Exit Function
End If
Next
End Function
Since the will always be at the beginning of the string, in this instance you
could use the Val function:
=============================
Option Explicit
Sub GetDigits()
Dim rg As Range, c As Range
Set rg = Selection
For Each c In rg
c.Offset(0, 1).Value = Val(Trim(c.Value))
Next c
End Sub
========================
--ron
|