View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default How to crop only numbers from a string?

Maybe:

Sub GetIt()
Dim str As String
str = "vivaldi - 4 - seasons - movement/1"
MsgBox num(str)

End Sub

Function num(inpt As String)
Dim i As Integer
For i = 1 To Len(inpt)
If IsNumeric(Mid(inpt, i, 1)) Then
num = num & Mid(inpt, i, 1)
End If
Next i
num = CLng(num)
End Function

Regards
Rowan

serdar wrote:
function should return number 41 from string:
"vivaldi - 4 - seasons - movement/1"