Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have a number in cell B1 that is generated from a simple sum formula. I want the background color in cell B4 to change depending on what value is displayed in B1. I know how to do that using CF or by use of the Select Case.Value code (See sample code below). Now what I want to do is also display a TEXT string in cell B4 that also changes based on the value displayed in cell B1. The color of the font in this text string will also need to change based on the value displayed in cell B1. Also I need help condensing this code a bit by using number ranges instead of each possible number that may be displayed in cell b1 Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Range("B1")) Is Nothing Then With Target Select Case .Value Case Is < 1: Range("B4").Interior.ColorIndex = 2 Case 1: Range("B4").Interior.ColorIndex = 10 Case 2: Range("B4").Interior.ColorIndex = 10 Case 3: Range("B4").Interior.ColorIndex = 10 Case 4: Range("B4").Interior.ColorIndex = 10 Case 5: Range("B4").Interior.ColorIndex = 10 Case 6: Range("B4").Interior.ColorIndex = 10 Case 7: Range("B4").Interior.ColorIndex = 6 Case 8: Range("B4").Interior.ColorIndex = 6 Case 9: Range("B4").Interior.ColorIndex = 6 Case 10: Range("B4").Interior.ColorIndex = 6 Case 11: Range("B4").Interior.ColorIndex = 6 Case 12: Range("B4").Interior.ColorIndex = 6 Case 13: Range("B4").Interior.ColorIndex = 3 Case 14: Range("B4").Interior.ColorIndex = 3 Case 15: Range("B4").Interior.ColorIndex = 3 Case 16: Range("B4").Interior.ColorIndex = 3 Case 17: Range("B4").Interior.ColorIndex = 3 Case 18: Range("B4").Interior.ColorIndex = 3 Case 19: Range("B4").Interior.ColorIndex = 3 Case 20: Range("B4").Interior.ColorIndex = 3 Case 21: Range("B4").Interior.ColorIndex = 3 Case 22: Range("B4").Interior.ColorIndex = 3 Case Is 22: Range("B4").Interior.ColorIndex = 3 End Select End With End If ws_exit: Application.EnableEvents = True End Sub P.S. I borrowed the initial Case Is code from someone on here but cant remember who it came from. But Thanks for the bones! JW |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formatting cells in a column with conditional formatting? | Excel Discussion (Misc queries) | |||
Protect Cell Formatting including Conditional Formatting | Excel Discussion (Misc queries) | |||
conditional Formatting based on cell formatting | Excel Worksheet Functions | |||
conditional Formatting based on cell formatting | Excel Worksheet Functions | |||
Conditional Formatting that will display conditional data | Excel Worksheet Functions |