There are several ways to do it. The standard way is pretty much to
construct a Range referencing the cells in the range and test the
intersection of that range and the Target. To do this, replace this line in
my code...
If Target.Address = "$A$1" Then
with this one...
If Not Intersect(Target, Range("$A$1,$L$15,$M$34")) Is Nothing
--
Rick (MVP - Excel)
How about in response to a double click (change the address for the cell
in
the first If..Then statement to the actual address of your cell and use
the
$ signs in the address)...
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Address = "$A$1" Then
Cancel = True
If Target.Value = "" Then
Target.Value = "X"
Else
Target.Value = ""
End If
End If
End Sub
To install this code, right click the tab at the bottom of the worksheet
you
want this functionality on, select View Code from the popup menu that
appears and copy/paste the above code into the code window that appeared.
Now, go back to the worksheet and double click the cell to put the "X" in
the cell, then double click it again to clear it. Instead of the "X" I
used,
you can change the font for the cell and then use any character you want.
--
Rick (MVP - Excel)
- Show quoted text -
Thanks for all your help. I am going to use Ricks code as below:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As
Boolean)
If Target.Address = "$A$1" Then
Cancel = True
If Target.Value = "" Then
Target.Value = "X"
Else
Target.Value = ""
End If
End If
End Sub
What If I had multiple cells where I would like this action to occur
could I do somethig as below:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As
Boolean)
If Target.Address = "$A$1" OR "$L$15" OR "$m$34" Then
Cancel = True
If Target.Value = "" Then
Target.Value = "X"
Else
Target.Value = ""
End If
End If
End Sub
thanks again