you need to use conditional formatting to do it
click on the cell and choose
format / conditional formatting
choose cell value is
for example
equals 10
press the format button - choose a formatting (back colours are on the
patterns tab)
click OK
now click ADD
choose cell value is
for example
greater than 20
format as required
click OK twice
to see the result
if you need additional help or you have a more complex IF statement (you can
have up to 3 conditions using this feature, more than that you need to use
code) post back
here's an example of conditional formatting applied to the range A1:A5 with
6 conditions, substitute the numbers next to the word "case" with your
conditions (e.g. Case "cat": ) & change the ci numbers to change the
colours.
****
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngArea As Range
Dim ci As Long
Set rngArea = Range("A1:A5")
If Not Intersect(Target, rngArea) Is Nothing Then
Select Case Target.Value
Case 1: ci = 3
Case 2: ci = 8
Case 3: ci = 24
Case 4: ci = 26
Case 5: ci = 17
Case 6: ci = 44
End Select
Target.Interior.ColorIndex = ci
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngArea As Range
Dim ci As Long
Set rngArea = Range("B1:B5") 'change this
If Not Intersect(Target, rngArea) Is Nothing Then
Select Case Target.Value
Case 1: ci = 3
Case 2: ci = 8
Case 3: ci = 24
Case 4: ci = 26
Case 5: ci = 17
Case 6: ci = 44
End Select
Target.offset(0,-1).Interior.ColorIndex = ci 'change this
End If
End Sub
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.