Hi all,
This is for Excel 2013, and here is my code, which has worked before:
When using this in a macro-enabled workbook, the #NAME ? result appears.
The function used to be just a normal function, which resides in my PERSONAL.XLSB, but changed to PUBLIC to see if that made a difference.
I have a habit of doing things, like formulae, in lower case, then seeing if it changes to the proper case after pressing Enter. The UDF is SumByColor(), but the formula shows sumbycolor().
Can someone let me know what I'm doing wrong?
Thank you,
This is for Excel 2013, and here is my code, which has worked before:
Code:
Public Function SumByColor(CellColor As Range, rRange As Range)
' CellColor is the cell containing they colour type you are searching for
' rRange is the range of cells to add, if the colour matches
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(c1, cSum)
End If
Next cl
SumByColor = cSum
End Function
When using this in a macro-enabled workbook, the #NAME ? result appears.
The function used to be just a normal function, which resides in my PERSONAL.XLSB, but changed to PUBLIC to see if that made a difference.
I have a habit of doing things, like formulae, in lower case, then seeing if it changes to the proper case after pressing Enter. The UDF is SumByColor(), but the formula shows sumbycolor().
Can someone let me know what I'm doing wrong?
Thank you,
Last edited: