Color macro
Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Const myRange As String = "A1:A10"
On Error GoTo endit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(myRange)) Is Nothing Then
With Target
If .Interior.ColorIndex = 3 Then
.Interior.ColorIndex = xlNone
Else
.Interior.ColorIndex = 3
End If
End With
Cancel = True 'preserve double-click edit for cells not in MyRange
End If
endit:
Application.EnableEvents = True
End Sub
This is sheet event code. Right-click on the sheet tab and "View Code".
Copy/paste into that sheet module.
Adjust MyRange to suit.
Gord Dibben MS Excel MVP
On Sat, 22 Sep 2007 19:35:56 -0400, Little Penny
wrote:
Is there a macro that will change the interior color of a cell on a
click or double click? And then change it back to the default if
clicked again. I want to be able to go back and forth.
Thanks
|