Macro to add value if cell has a color :-s

T

test

I don't know if this exists, but is it possible to check if a certain
cell has a color?

Normally a cell is blank, but someone asked me to see if it is
possible to check if a cell is colored..

Any suggestions?

Thanks!!!
 
D

Don Guillett

Is this sufficient?

Sub ifcolor()
If Range("b2").Interior.ColorIndex > 0 Then MsgBox "yep"
End Sub
 
T

test

Is this sufficient?

Sub ifcolor()
If Range("b2").Interior.ColorIndex > 0 Then MsgBox "yep"
End Sub

Hey thanks!!!
This works, but is it possible to add a value to lets say C3?
If B2 has a color, then C3=1

And, is it possible to run the macro everytime something changes???

Thanks very much!
 
D

Dave Peterson

Sub ifcolor()
If Range("b2").Interior.ColorIndex > 0 Then
range("C3").value = 1
else
'maybe...
range("C3").clearcontents '????
End if
End Sub
 
T

test

Sub ifcolor()
If Range("b2").Interior.ColorIndex > 0 Then
range("C3").value = 1
else
'maybe...
range("C3").clearcontents '????
End if
End Sub

This is great!!!

Is it possible to run this everytime something changes on the
spreadsheet?
 
D

Dave Peterson

Yep.

If the change is being made because the user is typing something into B2, then
you could use the worksheet_Change event.

If the value in B2 is changing because B2 contains a formula, then you could use
the worksheet_Calculate event.

What do you want use?
 
D

Don Guillett

I might suggest that you FULLY state your request in the OP. It makes life
easier for everyone. Just one of my "pet peeves". No, it goes further than
that. It REALLY hacks me off.
 
Top