pcwilson78
New Member
- Joined
- Nov 14, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi,
I have searched the forums for this and found an article with VBA code to change the colour of a cell based on a certain cell click with no problems. However, I need the cell to then clear the colour once another cell has been clicked
Example
Cell A4 is clicked (has focus)
Cell E4 changes to green
Cell A6 is clicked (has focus)
Cell E4 clears its colour
Cell E6 changes to green
Heres the VBA
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Sheets("Sheet1")
Select Case Target.Address
Case "$A$3"
.Range("R4").Interior.Color = RGB(0, 255, 255)
Case "$A$4"
.Range("Z13").Interior.Color = RGB(0, 255, 0)
Case "$A$5"
.Range("M8").Interior.Color = RGB(0, 255, 0)
End Select
End With
End Sub
Many thanks in advance
I have searched the forums for this and found an article with VBA code to change the colour of a cell based on a certain cell click with no problems. However, I need the cell to then clear the colour once another cell has been clicked
Example
Cell A4 is clicked (has focus)
Cell E4 changes to green
Cell A6 is clicked (has focus)
Cell E4 clears its colour
Cell E6 changes to green
Heres the VBA
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Sheets("Sheet1")
Select Case Target.Address
Case "$A$3"
.Range("R4").Interior.Color = RGB(0, 255, 255)
Case "$A$4"
.Range("Z13").Interior.Color = RGB(0, 255, 0)
Case "$A$5"
.Range("M8").Interior.Color = RGB(0, 255, 0)
End Select
End With
End Sub
Many thanks in advance