how can i change colour of a cell

C

Chip Pearson

Conditional Formatting on the Format menu can do this. First, select
the cell whose color should change. Then, open the Conditional
Formatting dialog from the Format menu. There, change "Cell Value Is"
to "Formula Is" and enter something like the following in the formula
box:

=A1>10

Change that formula to return TRUE or FALSE, indicating whether the
format should be applied. Then click the Format button and choose the
Pattern tab. Select the color to fill the cell. Click OK until you're
done. If the formula is TRUE (e.g., A1>10), the format you selected
will be applied to the cell. If the formula is FALSE, no format (other
than the cell's default format) will be applied to the cell.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
P

Patrick Molloy

put this code in the sheet's code page (right click the tab & click View
Code)


Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
' cell D4 triggers a colr change in E4
If Target.Address = "$D$4" Then
If IsNumeric(Target.Value) Then
Select Case Target.Value
Case 1 To 56
Range("E4").Interior.ColorIndex = Target.Value
Case Else
End Select
End If
End If
End Sub

to see all available colors, put this code into a standard module

Option Explicit
Sub ListColors()
Dim i As Long
On Error GoTo Quit
i = 1
Do
Cells(i, 1) = i
Cells(i, 2).Interior.ColorIndex = i
i = i + 1
Loop
Quit:
End Sub
 

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