网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

Excel VBA实现取字符串中数字并求和

时间:2024-10-12 13:02:01

1、ALT+F11打开VBE编辑器,单击菜单:工具-引用。

Excel VBA实现取字符串中数字并求和

3、新建一个模块,输入如下代码:Sub tsszstrqh()Dim reg As New RegExpDim str As String, t, s, arrstr = Range("a1").ValueWith reg.Global = True.Pattern = "[^0-9.]"arr = "=" & Right(.Replace(str, "+"), Len(.Replace(str, "+")) - 1).Pattern = "\++"Range("b1") = .Replace(arr, "+")End WithEnd Sub

Excel VBA实现取字符串中数字并求和
© 五度知识库