Thread: Toggle a cell
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Toggle a cell

Hi
use the Selection_Change event of your worksheet. Put the following code in
your worksheet module:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column < 1 Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub

Application.EnableEvents = False
If Target.Value < "" Then
Target.ClearContents
Else
Target.Value = "X"
End If
Application.EnableEvents = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

Brad K. wrote:
I've tried several methods but can't quite figure it out. How can I
write the code so that when I click on a cell within a column it will
toggle it (i.e. if blank, put an "X" value or if it has an "X" value
it will leave it blank).
I want this to happen whether I click on the active cell or on a new
cell within the column.
Also, how do I do this if it requires a double click.
Thanks,
Brad