Function add(rng As Range, rng1 As Range)
Dim cell As Range, i As Long, y As Long, r As Long, r1 As Long, u As Long, ws As Worksheet
Set ws = Sheets(rng1.Parent.Name)
r = rng.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
r1 = rng1.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
u = 1
Do Until u > r
If Cells(u, rng.Column).Value = "" Then
i = 0
Else
If IsNumeric(Cells(u, rng.Column).Value) = True Then
i = Application.Evaluate("Sum(" & i & "," & Cells(u, rng.Column).Value & ")")
End If
End If
u = u + 1
Loop
u = 1
Do Until u > r1
If ws.Cells(u, rng1.Column).Value = "" Then
y = 0
Else
If IsNumeric(ws.Cells(u, rng1.Column).Value) = True Then
y = Application.Evaluate("Sum(" & y & "," & ws.Cells(u, rng1.Column).Value & ")")
End If
End If
u = u + 1
Loop
add = i + y
End Function
|