R
Rob Severijns
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
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