Function SHUZI(AA As Range)
Dim n As Integer, i As Integer, tem
n = Len(AA.Value)
For i = 1 To n
If IsNumeric(Application.Find(Mid(AA.Value, i, 1), "0123456789")) Then
tem = tem & Mid(AA.Value, i, 1)
End If
Next
SHUZI = Val(tem)
End Function
Dim n As Integer, i As Integer, tem
n = Len(AA.Value)
For i = 1 To n
If IsNumeric(Application.Find(Mid(AA.Value, i, 1), "0123456789")) Then
tem = tem & Mid(AA.Value, i, 1)
End If
Next
SHUZI = Val(tem)
End Function
本文提供了一个使用VBA从字符串中提取所有数字并将其连接起来的示例代码。通过循环遍历输入字符串中的每个字符,并检查它们是否为数字,然后将数字字符组合成最终的数值。
6836

被折叠的 条评论
为什么被折叠?



