K
ker_01
I have some code that handles the doubleclick event on a target sheet
(relevant code pasted at the bottom of this post).
Approximately 30% of the time, when I try to double-click, the selected cell
(target) will randomly move to a different cell before my second click,
thereby not triggering the double-click event. It doesn't move my cursor; the
selected cell (highlighted) will actually suddenly jump to a different cell
leaving my cursor over my intended target cell. Example:
Cell E31 is selected (single click; the cursor is not within the cell so it
is not in edit mode)
I double click on cell D20 (very fast, inter-click delay is not an issue)
-the first click selects cell D20 ( the box around the cell highlights) as
expected
-the second click occurs, without moving the mouse
Some other random cell is selected, and my code does not fire.
While re-testing to write this email, once it jumped to cell D28, another
time it jumped to D11.
I've not had reason to use the double-click event before, and I've never
seen this behavior before- so I'm thinking that just having the double-click
event "enabled" may be causing problems. I can't see anything in my code that
would cause this behavior. I'm open to any ideas, because I'd really like to
get a reliable double-click on a target cell 100% of the time!
Note that I added the msgbox to confirm whether the code is firing- when the
selection jumps, I don't get the msgbox. When I do get the msgbox, the
everything processes as expected (userform and subsequent code all works fine)
Thanks,
Keith
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Msgbox "x"
If Target.Rows.Count = 1 And Target.Columns.Count = 1 Then
NameVal = Target.Value
If NameVal <> "" And Target.Row > 2 And (Target.Column = 3 Or
Target.Column = 4 Or Target.Column = 5) Then
UserForm1.show
End If
End If
End Sub
(relevant code pasted at the bottom of this post).
Approximately 30% of the time, when I try to double-click, the selected cell
(target) will randomly move to a different cell before my second click,
thereby not triggering the double-click event. It doesn't move my cursor; the
selected cell (highlighted) will actually suddenly jump to a different cell
leaving my cursor over my intended target cell. Example:
Cell E31 is selected (single click; the cursor is not within the cell so it
is not in edit mode)
I double click on cell D20 (very fast, inter-click delay is not an issue)
-the first click selects cell D20 ( the box around the cell highlights) as
expected
-the second click occurs, without moving the mouse
Some other random cell is selected, and my code does not fire.
While re-testing to write this email, once it jumped to cell D28, another
time it jumped to D11.
I've not had reason to use the double-click event before, and I've never
seen this behavior before- so I'm thinking that just having the double-click
event "enabled" may be causing problems. I can't see anything in my code that
would cause this behavior. I'm open to any ideas, because I'd really like to
get a reliable double-click on a target cell 100% of the time!
Note that I added the msgbox to confirm whether the code is firing- when the
selection jumps, I don't get the msgbox. When I do get the msgbox, the
everything processes as expected (userform and subsequent code all works fine)
Thanks,
Keith
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Msgbox "x"
If Target.Rows.Count = 1 And Target.Columns.Count = 1 Then
NameVal = Target.Value
If NameVal <> "" And Target.Row > 2 And (Target.Column = 3 Or
Target.Column = 4 Or Target.Column = 5) Then
UserForm1.show
End If
End If
End Sub