ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Enter value in cell by selecting cell. (https://www.excelbanter.com/excel-discussion-misc-queries/117097-enter-value-cell-selecting-cell.html)

Greyson

Enter value in cell by selecting cell.
 
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?

Dave Peterson

Enter value in cell by selecting cell.
 
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.

Greyson wrote:

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?


--

Dave Peterson

Dave Peterson

Enter value in cell by selecting 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.

Greyson wrote:

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?


--

Dave Peterson


All times are GMT +1. The time now is 01:52 PM.

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