Shading a cell using an if statement

  • Thread starter Thread starter Dan Gaynor
  • Start date Start date
D

Dan Gaynor

Hi Group,
What I am trying to do is to shade a cell when an arguement is true.
if(a3=10,shade cell,don't shade cell)

thanks a bunch for any help!!
 
Hi
this is not possible with formulas as they can only return values but
not change formats. The only way would be to use VBA and create an
event procedure. e.g. something like the following (this code goes into
your worksheet module):
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
With Target
If .Value = 10 Then
.Interior.ColorIndex = 3
End If
End With
End Sub
 
One option would be via conditional formatting ?

If you want A3 to be shaded light green
when the value in it is 10 or more

Select A3
Click Format > Conditional Formatting
Make the settings under Condition 1:
Cell Value Is| greater than or equal to| 10
Click Format button > Patterns tab > Light green > Ok
Click OK at the main dialog

If you want the fill color to appear in a cell other
than A3, say in the adjacent B3, you could try ..

Select B3
Click Format > Conditional Formatting
Make the settings under Condition 1:
Formula Is | =A3>=10
Click Format button > Patterns tab > Light green > Ok
Click OK at the main dialog
 
Of course, if you wanted the shading to appear only if A3=10
just amend the settings accordingly to:
 
Back
Top