The following code does one of three things
1. Copies
3. Pastes
2. If copy and paste have already been done, the Double click transfers you to the event sheet.
I use a counter in "A1" to establish what we are doing (1 or zero)
My problem is, that if someone starts the process, with a zero and therefore is copying, if they hit the Esc key before the second double click (the Paste) the counter doesn't get reset.
How do I include
Range ("A1") = 0
if the ESC key is hit.
Thank you.
1. Copies
3. Pastes
2. If copy and paste have already been done, the Double click transfers you to the event sheet.
I use a counter in "A1" to establish what we are doing (1 or zero)
My problem is, that if someone starts the process, with a zero and therefore is copying, if they hit the Esc key before the second double click (the Paste) the counter doesn't get reset.
How do I include
Range ("A1") = 0
if the ESC key is hit.
Thank you.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Const WS_RANGE As String = "B:B"
Const WS_DESTN As String = "G6:K68"
Dim WsName As String
On Error GoTo ws_exit
Cancel = True 'rid protection error
'Copy event
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
If Range("A1") = 0 Then
With Target
ActiveCell.Copy
End With
Range("A1") = 1
End If
GoTo ws_exit
Else
If Not Intersect(Target, Me.Range(WS_DESTN)) Is Nothing Then
'Go to the event
If Range("A1") = 0 Then
WsName = Target.Value
With Target
Sheets(WsName).Visible = True
Sheets(WsName).Select
End With
Else
'Paste event
If Range("A1") = 1 Then
With Target
ActiveCell.PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
End If
End If
End If
Range("A1") = 0 'Reset counter
End If
ws_exit:
End Sub