Question

I have a double click event where I want it to hold the copy of a certain range.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("A3:A25, A29:A34, A36:A40, F3:F14, F18:F21, F25:F26, F3:F32, F36:F37, K3:K22, K26:K40, P3:P22")) Is Nothing Then
        Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 3)).Copy
    End If
End Sub

When I click on one of the ranges, I can see the copy highlight come around quickly and disappear. How do I hold this to clipboard? Ideally I'd like to be able to paste this range on the next double click event as well.

Was it helpful?

Solution

try this:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, _
Range("A3:A25, A29:A34, A36:A40, F3:F14, F18:F21, F25:F26, F3:F32, F36:F37, K3:K22, K26:K40, P3:P22")) Is Nothing Then
    Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 3)).Select
End If
Selection.Copy
End Sub

I've tested it and it works. :D

Edit1: This also works

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = False
If Not Intersect(Target, _
Range("A3:A25, A29:A34, A36:A40, F3:F14, F18:F21, F25:F26, F3:F32, F36:F37, K3:K22, K26:K40, P3:P22")) Is Nothing Then
    Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 3)).Copy
Else
    Application.CutCopyMode = False
End If
Cancel = True
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top