A formula to type 1 in B2 if A2 has the color green?

H

Henrik

Is there a way to make a formula that recognizes the cell color like if A2 is
green, then my formula in B2 would recognize this color and return the value
1, then 0 for yellow and -1 for red for example. - a form of reverse
conditional formatting.

If not, how to to this in vba?

Rgds
 
J

Jacob Skaria

Try the below UDF; will return the color index of a cell

=GetColorIndex(A1)
will return 0 if not filled. Now you can combine this with IF formula to
suit your requirement.

Function GetColorIndex(varRange)
GetColorIndex = varRange.Interior.ColorIndex
If GetColorIndex = -4142 Then GetColorIndex = 0
End Function

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top