changing cell colour on click

N

Nimbus55

I'd like to see a cell change colour when a user clicks it...How would I do
that?
Thanks
 
J

JE McGimpsey

Would you settle for a double-click?

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
Cancel = True
With Target.Interior
.ColorIndex = IIf(.ColorIndex = 3, xlColorIndexNone, 3)
End With
End Sub

You could do the same thing with a single click by using the
Worksheet_SelectionChange() event macro, but that would also be
triggered by tabbing, the Enter and arrow keys, etc.
 
J

JE McGimpsey

Forgot to say that this should go in your worksheet code module
(right-click the worksheet tab and choose View Code)
 
N

Nimbus55

Thank you....it's perfect!

JE McGimpsey said:
Forgot to say that this should go in your worksheet code module
(right-click the worksheet tab and choose View Code)
 
Top