调用示例
=求和(B3:C4,D3:D7,B6:C7,C8:D8)
Public Function 求和(ParamArray 区域()) As Single
On Error Resume Next
Dim Str1 As String, Str2 As String, Str3 As String, Str4 As String
Dim i As Integer
Dim sum As Integer
sum = 0
For Each 区域1 In 区域
For Each cell In 区域1
Str1 = cell.Text
If Str1 <> "" Then
Str2 = "1234567890.+-*/ ()×"
Str4 = ""
For i = 1 To Len(Str1)
Str3 = Mid(Str1, i, 1)
If InStr(1, Str2, Str3) > 0 Then
Str4 = Str4 & Str3
End If
Next
Str4 = Replace(Str4, "×", "*")
Str4 = Evaluate(Str4)
If IsNumeric(Str4) = True Then
sum = sum + Str4
End If
End If
Next cell
Next 区域1
求和 = sum
End Function
记得加分啊 (先提高悬赏,再加分呵呵)