天气

excel中间有文字求和


VBA代码:

Sub test()
    Dim reg As Object
    Dim mat, m, st
    Dim rg As Range
    Set reg = CreateObject("VBScript.RegExp")
    For Each rg In Range("a1:a" & [a65536].End(xlUp).Row)
        With reg
            .Global = True
            .Pattern = "\d+"
            Set mat = .Execute(rg)
            For Each m In mat
                st = st + Val(m)
            Next m
            rg.Offset(, 1) = st
            st = 0
        End With
    Next
End Sub

标签:
分类:Excel学习| 发布:admin| 查看: | 发表时间:2012/3/21
原创文章如转载,请注明:转载自个人资讯网 http://www.zhangxinran.com/
本文链接:http://www.zhangxinran.com/post/72.html

相关文章

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Design By zhangxinran.com | Login | Power By zhangxinran.com | 皖公网安备:34010402701072号