I'm trying to display the colour from the conditional formatting in excel. In excel I simply use =CheckColour(B5) for example, and when I hit return it works. However, when I ask the sheet to calculate, the function gives #VALUE! and I don't know where I've gone wrong. Any help is appreciated as I'm a beginner at VBA. Thanks
Function CheckColour(range)
If range.DisplayFormat.Interior.Color = RGB(255, 0, 0) Then
CheckColour = "Red"
ElseIf range.DisplayFormat.Interior.Color = RGB(0, 130, 59) Then
CheckColour = "Green"
Else
CheckColour = "Amber"
End If
End Function
Public Function CheckColour(ByVal target As Range) As String- right now it's implicitly public,rangeis implicitlyByRefandVariant, and the function implicitly returns aVariant.