(Solved) – Custom VBA Function keeps returning #VALUE [duplicate]

(solved)-–-custom-vba-function-keeps-returning-#value-[duplicate]

I am new to the VBA Function and I wrote a very simple function to test if the background of a cell is filled with a particular color. However, the return value is always #VALUE!. It should be a very simple mistake but still can’t find where the problem is after I tried different methods to fix it. I attached the code I wrote below. Can anybody help me with my problem?

Thanks

Function SAFETY(Cell As Range) As Boolean
Application.Volatile
If (Cell.DisplayFormat.Interior.Color = 7040761) Then
SAFETY = True
Else
SAFETY = False
End If
End Function

Update:

I checked the formula with the Insert Function section under Formulas Tab, the return value is actually TRUE. However, it just cannot displayed on the worksheet cell. enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *