Hello, I have been googling and searching an answer but I can't find anything. I have a sheet which highlights certain cells with conditional formatting. I need to sum these cells so I have written a macro and it works and the formula result is correct but in the worksheet it shows as #VALUE!. I have checked the cell format and everything is as it should be. Can someone please help me?
VBA Code:
Option Explicit
Function SumColor(sumRange As Range) As Double
Application.Volatile
Dim cell As Range
For Each cell In sumRange
If cell.DisplayFormat.Interior.Color = 5296274 Or cell.DisplayFormat.Interior.Color = 15773696 Or cell.DisplayFormat.Interior.Color = 49407 Or cell.DisplayFormat.Interior.Color = 12566463 Then
SumColor = SumColor + cell.Value
End If
Next cell
End Function