I have the following formula
Public Function CofM(location As Range, mass As Range) As Variant
Dim dbDivisor As Double
dbDivisor = Application.Sum(mass)
If Not dbDivisor = 0 Then
CofM = Application.SumProduct(location, mass) / dbDivisor
Else
CofM = CVErr(xlErrDiv0)
End If
End Function
which works fine when my inputs are =CofM(RangeA,RangeB)
however I need it to also work with =CofM((cell1,cell2,cell3),(cell4,cell5,cell6))
How do I get it to accept RangeA or cell1,cell2,cell3 or cell1,RangeA,cell2 as Array1?
I have been trying to use =SumProduct((cell1,cell2,cell3),(cell4,cell5,cell6)) in varying forms to see if SumProduct can build an array from selected cells (similar to how Sum can be =Sum(range) or =Sum(num1,num2,num3)) with no luck so far.
Bookmarks