PDA

View Full Version : Highlight the last selected cell



uktous
10-13-2012, 09:52 AM
Hi,

How can I highlight the last selected cell?

It is easy to highlight the current selected cell, but I don’t know how to highlight the last selected cell.


Macro for highlighting the current selected cell:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Selection.Interior.Color = 65535

End Sub


Thanks

mikerickson
10-13-2012, 10:19 AM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static PreviousCell As Range

If Not PreviousCell Is Nothing Then
Cells.Interior.ColorIndex = xlNone
PreviousCell.Interior.Color = 65535
End If
Set PreviousCell = Target.Cells(1, 1)
End Sub

winon
10-13-2012, 02:48 PM
@ mikerickson,

Very good!:)