In the below code I am defining the sections of the worksheet id like to highlight. Why will cell fill color of the rest of the worksheet not hold. If I try to fill another cell it just goes back to no fill.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Sheets("raise")
.Cells.Interior.ColorIndex = xlColorIndexNone
Select Case Target.Address
Case "$C$7"
.Range("C16:h16").Interior.Color = RGB(0, 255, 0)
.Range("C7:h7").Interior.Color = RGB(0, 255, 0)
Case "$C$8"
.Range("c17:h17").Interior.Color = RGB(0, 255, 0)
.Range("c8:h8").Interior.Color = RGB(0, 255, 0)
Case "$C$9"
.Range("c18:h18").Interior.Color = RGB(0, 255, 0)
.Range("c9:h9").Interior.Color = RGB(0, 255, 0)
Case "$C$10"
.Range("c19:h19").Interior.Color = RGB(0, 255, 0)
.Range("c10:h10").Interior.Color = RGB(0, 255, 0)
Case "$C$11"
.Range("c20:h20").Interior.Color = RGB(0, 255, 0)
.Range("c11:h11").Interior.Color = RGB(0, 255, 0)
Case "$C$12"
.Range("c21:h21").Interior.Color = RGB(0, 255, 0)
.Range("c12:h12").Interior.Color = RGB(0, 255, 0)
End Select
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Sheets("raise")
.Cells.Interior.ColorIndex = xlColorIndexNone
Select Case Target.Address
Case "$C$7"
.Range("C16:h16").Interior.Color = RGB(0, 255, 0)
.Range("C7:h7").Interior.Color = RGB(0, 255, 0)
Case "$C$8"
.Range("c17:h17").Interior.Color = RGB(0, 255, 0)
.Range("c8:h8").Interior.Color = RGB(0, 255, 0)
Case "$C$9"
.Range("c18:h18").Interior.Color = RGB(0, 255, 0)
.Range("c9:h9").Interior.Color = RGB(0, 255, 0)
Case "$C$10"
.Range("c19:h19").Interior.Color = RGB(0, 255, 0)
.Range("c10:h10").Interior.Color = RGB(0, 255, 0)
Case "$C$11"
.Range("c20:h20").Interior.Color = RGB(0, 255, 0)
.Range("c11:h11").Interior.Color = RGB(0, 255, 0)
Case "$C$12"
.Range("c21:h21").Interior.Color = RGB(0, 255, 0)
.Range("c12:h12").Interior.Color = RGB(0, 255, 0)
End Select
End With
End Sub