Functions do not have access to formatting directly.
You can do this with a User Defined Function, but there are several
caveats...
First, put this macro in a regular code module (Option+F11 to enter the
VBE, choose Insert/Module, then type or paste):
Public Function MyColor() As Long
If TypeName(Application.Caller) = "Range" Then
MyColor = Application.Caller.Interior.ColorIndex
End If
End Function
(Option F11 to return to XL).
Then use
=IF(MyColor()=7,"Do something", "Do something else")
Caveat 1: Changing format does not trigger a calculation event, so
changing cell interior colors will not result in a change in the value. You
can cause the sheet to recalculate by typing CMD=
Caveat 2: Cells are only recalculated if they contain a volatile
function or if their precedents change. To make the function above
volatile, use something like:
=IF(MyColor=7+RAND()*0,"Do something", "Do something else")
Now that function will recalculate if you type CMD=