JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,691
- Office Version
- 365
- Platform
- Windows
This function works if I pass it a list of cell addresses, like =Rangesum(C4,D4,E4)
But it gets a value error if I call it with a range, like "RangeSum(C4:E4)" or "RangeSum((C4:E4))".
Is there any way to write the function so that both calls will work, like the Sum function, which works either way?
Code:
Function RangeSum(ParamArray list())
Dim i As Integer
RangeSum = 0
For i = 0 To UBound(list)
RangeSum = RangeSum + list(i)
Next i
But it gets a value error if I call it with a range, like "RangeSum(C4:E4)" or "RangeSum((C4:E4))".
Is there any way to write the function so that both calls will work, like the Sum function, which works either way?
Code:
=Sum(C4,D4,E4)
=Sum(C4:E4)
Last edited: