Ciao Paolo ed Alessandro...
ed una soluzione un po' vintage cosi : (....meglio la prima a questo punto...)
un saluto.
Sub extractNumber3()
Dim strString As String, strNumber As String
Dim i As Integer
strString = "asvas74777vasdvasdvdavvvv88svdas7654321asvasdvdasvasdvdasv"
i = 1
Do While Len(strNumber) < 7
If Val(Mid(strString, i, 1)) Then
strNumber = strNumber & Mid(strString, i, 1)
Else
If Len(strNumber) > 0 Then strNumber = ""
End If
i = i + 1
Loop
Debug.Print strNumber
End Sub
[code]
Sub extractNumber()
Dim strString As String, strNumber As String
Dim i As Integer
strString = "asvas74777vasdvasdvdavvvv88svdas7654321asvasdvdasvasdvdasv"
For i = 1 To Len(strString)
If Len(strNumber) = 7 Then Exit For
If Asc(Mid(strString, i, 1)) > 47 And Asc(Mid(strString, i, 1)) < 58 Then
strNumber = strNumber & Mid(strString, i, 1)
End If
If Len(strNumber) > 0 And Not (Asc(Mid(strString, i, 1)) > 47 And Asc(Mid(strString, i, 1)) < 58) Then
strNumber = ""
End If
Next
Debug.Print strNumber
End Sub