数字だけ取ってくるVBA function


Function suuji(rg As Range) As Integer
    Dim moji As String
    Dim lim As Integer
    Dim itimoji As String
    moji = rg.Text
    lim = Len(moji) '文字数
    For i = 1 To lim
        itimoji = Mid(moji, i, 1) 'mojiから一文字だけ取る
        If IsNumeric(itimoji) Then
            suuji = suuji & itimoji
        End If
    Next
End Function