Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I Use the following code to set the interior color af a cell:
Private Sub Worksheet_Change(ByVal Target As Excel.Range) Application.ScreenUpdating = False If Not Intersect(Target, Range("$M6:$M1006")) Is Nothing Then With Target Select Case .Value Case Is = "Nld", "Bel" .Offset(0, -11).Resize(1, 3).Interior.ColorIndex = 35 Case Else .Offset(0, -11).Resize(1, 3).Interior.ColorIndex = xlNone End Select End With End If End Sub and this to color a selected row: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.ScreenUpdating = False If Intersect(ActiveCell, Range("B6:AO1006")) Is Nothing Then Exit Sub Dim RngRow As Range Dim RngCol As Range Dim RngFinal As Range Dim Row As Long Dim Col As Long Range("A1:IU6").Cells.Interior.ColorIndex = xlNone Range("B6:IU1006").Cells.Interior.ColorIndex = xlNone Row = Target.Row Col = Target.Column Set RngRow = Range("B" & Row, Range("AO" & Row, Target)) Set RngCol = Range(Cells(1, Col), Target) Set RngFinal = RngRow RngFinal.Interior.ColorIndex = 36 Range("B4:AO5").Cells.Interior.ColorIndex = 35 End Sub Unfortunatly, when I select another cell or row the color, set by the first part of the code, disappears. Q: What would the code be to make sure that I don't loose the interior color if the conditions in the first part of the code are met and also make sure that the entire row is colored when the condition is not met. With kind regards. Rob Severijns |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Set text color to interior color | Excel Programming | |||
Interior color | Excel Programming | |||
Cell background color (interior color) setting not working | Excel Programming | |||
Interior color | Excel Programming | |||
Passing Back Color to Interior Color | Excel Programming |