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
- How to insert rows in excel automatically based on cell value without vba ✓ - Excel Forum
- Based on the cell values in cells b77 - Excel Forum
- Cell phone codes - Guide
- Excel cell color formula - Guide
- Insert a function in cell b2 to display the current date from your system. ✓ - Excel 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