I have a script that changes a cell's interior (fill) color when the cell is selected using the SelectionChange event, if the selected cell lies within a specific range. It also copies the cell's value to another cell.
[VBA]Private Sub Worksheet_SelectionChange(ByVal Target As Range
Const WS_RANGE As String = "G4:G50" 'target range
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target 'if user selects cell in target range
Range("F4").Value = ActiveCell.Value 'copy selected cell value to F4
With Selection.Interior 'and change fill colour of selected cell
.Color = 16777164
What I would like to figure out is how to change the selected cell's interior colour back to what it was when I click another cell in the targeted range such that only the currently selected cell is highlighted/filled. Any and all suggestions greatly appreciated!