Format cell based on data in a different cell
Closed
MK
-
Oct 16, 2009 at 07:03 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Oct 17, 2009 at 01:43 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Oct 17, 2009 at 01:43 AM
Related:
- Format cell based on data in a different cell
- Format factory - Download - Other
- Clear only the formatting from the selected cell (leaving the content) - Guide
- An example of a cell is a blank cell ✓ - Programming Forum
- Count if cell contains number - Excel Forum
- If cell contains date then return value ✓ - Office Software Forum
1 response
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Oct 17, 2009 at 01:43 AM
Oct 17, 2009 at 01:43 AM
right click sheet tab and click view code
in the resulting window copy this event code
now type
0 in A1 see what happens to B2
.05
.09
in the resulting window copy this event code
Private Sub Worksheet_Change(ByVal Target As Range) Dim r As Range If Target.Address <> "$A$1" Then Exit Sub Set r = Range("B2") If Target = 0 Then With r .Value = "red" .Interior.ColorIndex = 3 End With ElseIf Target > 0 And Target <= 0.08 Then With r .Value = "yellow" .Interior.ColorIndex = 6 End With ElseIf Target > 0.08 Then With r .Value = "green" .Interior.ColorIndex = 4 End With End If End Sub
now type
0 in A1 see what happens to B2
.05
.09