Hi,
I found a change event code that changes the color of the selected cell on:
http://www.cpearson.com/excel/excelM.htm
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object,
ByVal Target As Excel.Range)
Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target
End Sub
I really like what it does. Except it removes any existing color that was in the cell before selecting it.
I have tried modifying the code to return the original cell to its original color before it was selected.
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Static OldCell As Range
Static cellcolor As String
cellcolor = ActiveCell.Interior.ColorIndex
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = cellcolor
End If
Target.Interior.ColorIndex = 6
Set OldCell = Target
End Sub
However, I didn't do a very good job.
Instead of returning the cell to its original color, it moves that selected cells color to the previously selected cell.
I need help/advise on changing the code.
And I am hoping to get it to change the color of a cell that is affected by conditional formatting.
Hope someone can help with this.
Thanks,
Bookmarks