View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Can I set a specific excel cell to enter an 'X' when clicked

I'd recommend using a double-click event rather than a single-click
(selection), since selection also fires when the cell is tabbed or
arrowed into.

Put this in your worksheet code module:

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
With Target
If Not Intersect(.Cells, Range("B1:B10")) Is Nothing Then
Cancel = True
If IsEmpty(.Value) Then
.Value = "X"
Else
.ClearContents
End If
End If
End With
End Sub

Change the range ("B1:B10") to suit.

OTOH, you could also use a checkbox from the Forms toolbar and link it
to a cell.


In article ,
Test Creator <Test wrote:

Another issue to finalize my format for building an automatted test form.
Can I identify a specific excel cell, where if 'clicked', will enter an 'X',
if 'clicked again' will remove any existing 'x'?