Shading a cell using an if statement

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!!
 
F

Frank Kabel

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
 
M

Max

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
 
M

Max

Of course, if you wanted the shading to appear only if A3=10
just amend the settings accordingly to:
 

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