誰かが英数字セルに数値を追加するのを手伝ってくれますか?
例えば、
Function onlyDigits(s As String) As String
'Variables needed (remember to use "option explicit"). '
Dim retval As String ' This is the return string. '
Dim i As Integer ' Counter for character position. '
' Initialise return string to empty '
retval = ""
' For every character in input string, copy digits to '
' return string. '
For i = 1 To Len(s)
If Mid(s, i, 1) >= "0" And Mid(s, i, 1) <= "9" Then
retval = retval + Mid(s, i, 1)
End If
Next
' Then return the return string. '
onlyDigits = retval
End Function
結果:
Dim myStr as String myStr = onlyDigits ("3d1fgd4g1dg5d9gdg") MsgBox (myStr)
314159 の合計は 23 です。