ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I set a specific excel cell to enter an 'X' when clicked (https://www.excelbanter.com/excel-programming/329169-can-i-set-specific-excel-cell-enter-x-when-clicked.html)

Test Creator

Can I set a specific excel cell to enter an 'X' when clicked
 
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'?

JE McGimpsey

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'?



All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com