VBA function - Inputting multiple cells instead of a complete range of cells?
Hi everyone,
I have a vba function that returns the logarithmic average of a selected range of cells.
I want to be able to pick individual cells from across the worksheet as inputs to the function, instead of having to select a continuous range of cells.
Here is the current script. Any help would be greatly appreciated...
Code:
Function logsum(rngValues As Variant) As Variant
With Application.WorksheetFunction
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim SumValues As Double
Dim Antilog As Double
Dim rngLoop As Variant
SumValues = 0
Antilog = 0
'Add the antilogs of the values in the range
For Each rngLoop In rngValues
Antilog = .Power(10, 0.1 * rngLoop.Value)
SumValues = SumValues + Antilog
Next
'Perform logarithmic average
logsum = 10 * .Log10(SumValues)
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End With
End Function
Cheers,
Jimmy.