View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default click event for changing cell color

Liglin,

Put the following code in the ThisWorkbook code module.


Private Sub Workbook_SheetSelectionChange( _
ByVal Sh As Object, ByVal Target As Range)
Static OldCI As Integer
Static OldRng As Range
If Not OldRng Is Nothing Then
OldRng.Interior.ColorIndex = OldCI
End If
OldCI = Target.Interior.ColorIndex
Set OldRng = Target
Target.Interior.ColorIndex = 3 'red
End Sub

You might also be interested in my RowLiner addin at
www.cpearson.com/excel/rowliner.htm .


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"liglin" wrote in message
m...
Hello,

I would like to write a macro that changes the color of a cell

to red
when it is clicked - could anyone help me with the click or
onmousedown event?

Thanks,
Liglin