gpt4 book ai didi

excel - 通过双击事件复制/粘贴

转载 作者:行者123 更新时间:2023-12-03 02:50:07 31 4
gpt4 key购买 nike

我有一个双击事件,我希望它保存特定范围的副本。

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

当我单击其中一个范围时,我可以看到复制突出显示很快出现并消失。我如何将其保存到剪贴板?理想情况下,我希望也能够将此范围粘贴到下一个双击事件中。

最佳答案

试试这个:

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

我已经测试过它并且有效。 :D

编辑1:这也有效

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

关于excel - 通过双击事件复制/粘贴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21572935/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com