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

  • Thread starter Thread starter test
  • Start date Start date
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!!!
 
Is this sufficient?

Sub ifcolor()
If Range("b2").Interior.ColorIndex > 0 Then MsgBox "yep"
End Sub
 
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!
 
Sub ifcolor()
If Range("b2").Interior.ColorIndex > 0 Then
range("C3").value = 1
else
'maybe...
range("C3").clearcontents '????
End if
End Sub
 
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?
 
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?
 
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.
 
Back
Top