rodrigosantosbr

Excel Formula Cell Based on Background color

Jul 5th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Open the VBA editor and add a new module.
Do this by going to the Developer tab and clicking Visual Basic.
If you don't have the developer tab on the ribbon you will need to add it (do a quick Google search).
Once the VBA editor is open, right click on the VBA project which has your workbook name on the left and insert a module.

Place the following code into the new module:

Function IsRed(rng As Range) As Integer
    IsRed = (rng.Interior.Color = vbRed) * -1
End Function

then you can use the formula

=IsRed(A1)

to determine if A1 has a red background

note: this uses the default red in the standard colours

Add Comment
Please, Sign In to add comment