Stephen_IV
Well-known Member
- Joined
- Mar 17, 2003
- Messages
- 1,168
- Office Version
- 365
- 2019
- Platform
- Windows
I am looking to modify my code below. I need to update my function to be able to lookup a school and get the sum. For instance, Jefferson and get 167 or Washington and get 241. Thanks in advance.
VBA Sum Parenthesis Range.xlsm | |||
---|---|---|---|
A | |||
1 | Jefferson(100), Madison(25) | ||
2 | Washington(230), Jackson(23), Lincoln(243) | ||
3 | Beardsley(35), Jefferson(24) | ||
4 | Cleveland(223) | ||
5 | Lincoln(9), Washington(11), Jefferson(43) | ||
Sheet2 |
VBA Code:
Function SumP(r As Range) As Variant
Dim i As Long
Dim Parts() As String
For Each xcell In r
Parts = Split(Replace(xcell, ")", "("), "(")
For i = 1 To UBound(Parts)
SumP = SumP + Val(Parts(i))
Next
Next
End Function