Search : in
By :

Format cell based on data in a different cell

Last answer on Oct 17, 2009 6:43:34 am BST MK, on Oct 16, 2009 12:03:55 pm BST 
 Report this message to moderators

Hello,

I have a request to format a cell based on certain ranges and display in a "traffic light" (red/yellow/green) like manner for a dashboard.
For example: If the value of A1 = 0 then cell B2 should have a background color of red and display the word "Red". By having the word "Red" in the cell, if the spreadsheet is printed in gray scale, the user will still know what color it is. If A1 (> 0 and <= .08) then cell B2 should display the word "Yellow" and have yellow as a background color. If A1 > .08 then B2 should display the word "Green" and have the background color of green.
Is this possible?
Thanks,
MK

Configuration: Windows XP
Firefox 3.0.12

Best answers for « Format cell based on data in a different cell » in :
Excel tips : How to insert date in a cell ShowExcel tips : How to insert date in a cell Below are some tips on how to insert date and time in an excel cell for a specific purpose:- To insert current date, press CTRL ¯+ ;¯ in the chosen cell. To insert current time, press CTRL¯+...
Colouring cells on conditions ShowColouring cells on conditions There are many pratical functions under Excel which is not commonly used. Example: If you wish a cell automatically turns red (or other formatting border, frame etc) under one condition: a result, a...
How to split data into multiple worksheets? ShowHow to split data into multiple worksheets? Issue Solution Note Issue I hope someone can help! I have a .csv file open with excel that contains a large amount of data that has been merged together so that each data set follows each...
Base64 encoding ShowBase64 encoding The concept of Base64 encoding entails using US-ASCII (non-accented) characters to encode any sort of data in 8-bit form. Email protocols were originally designed to send messages in plain text only. But as email systems vary...
Spreadsheets - Cell Selection ShowCell Selection Spreadsheets are powerful tools for working with data. However, to work with data, it is necessary to have tools to rapidly choose the required cells. Line Selection An entire line can be chosen by clicking directly on the line...
Spreadsheet - Formulas ShowIntroduction to Formulas The main use of a spreadsheet is to automate calculations, which means using cells to perform operations based on values in other cells. The spreadsheet recalculates all the values each time a change is made to the value of...

1

 venkat1926, on Oct 17, 2009 6:43:34 am BST

Right click sheet tab and click view code
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

Reply to venkat1926