Enter value in cell by selecting cell.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I move the mouse cursor over a cell and click to select the cell I would
like for an "X" to be placed in the cell without entering the "X" with a
keyboard stroke. How do I accomplish this?
 
How about using doubleclicking and rightclicking:

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub

Cancel = True 'stop editing in cell
Target.Value = "X"
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub

Cancel = True 'stop pop up from showing
Target.Value = ""
End Sub

I used any cell in Column A. You can change that in both spots if you want.
Doubleclicking will add the X. Rightclicking will empty the cell.
 
ps.

If you want to try, rightclick on the worksheet tab that should have this
behavior. Select view code and paste that code into the code window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top