Hi folks
I have a handful of customised "SUM" functions in my spreadsheet, e.g. SUMSUB, SUMCAT, which calculate the values of cells with specific style names in a column.
Today I noticed that these functions are either ignoring the decimal places or rounding them up to the nearest full number.
Example: 0.50 and below is treated as "0", whereas 0.51 and above is treated as "1".
(Any formulas which use the default "SUM" are working correctly.)
Quote:
Function SumCat(WorkRng As Range)
'
' Calculates cells formatted as "Total Category"
' Example: =SUMCAT(A1:C9)
'
Application.Volatile
Dim rng As Range
Dim xSum As Long
For Each rng In WorkRng
' Finds cells with "Total Category" stylename
If rng.Style = "Total Category" Then
xSum = xSum + rng.Value
End If
Next
SumCat = xSum
End Function
|
Can anyone help? Number formatting is set to two decimal places and I would like my customised Functions to calculate them accurately.