How to extract groups of numbers from a string in vba

后端 未结 4 1011
栀梦
栀梦 2020-12-01 23:00

I have a string of the following shape:

RRP 90 AVE DE GAULLE 92800 PUTEAUX 0109781431-0149012126

The numbers might be seperated by other ch

4条回答
  •  Happy的楠姐
    2020-12-01 23:50

    Try below code :

    Function parseNum(strSearch As String) As String
    
       ' Dim strSearch As String
        'strSearch = "RRP 90 AVE DE GAULLE 92800 PUTEAUX 0109781431-0149012126"
    
        Dim i As Integer, tempVal As String
        For i = 1 To Len(strSearch)
            If IsNumeric(Mid(strSearch, i, 1)) Then
                tempVal = tempVal + Mid(strSearch, i, 1)
            End If
        Next
    
        parseNum = tempVal
    End Function
    

提交回复
热议问题