excel - 如何在 Excel VBA/宏中处理 CTRL-V?
问题描述
我有一个 VBA 宏,每次将单个值输入到 A 列(Workbook_SheetChange)的单元格中时,它都会启动。
一些用户将多个单元格或一整行或多行整行粘贴到工作表中以使其更容易(CTRL-V)。
如果粘贴整行/行,则宏会失败,有时整个 VBA_engine 会损坏,用户需要重新启动 Excel。
我想以在按下 CTRL-V 之后但在将内容粘贴到单元格之前禁用 VBA 代码的方式处理粘贴(CTRL-V)。之后应启动 VBA 代码。
我怎样才能做到这一点?
解决方案
问题是编写Worksheet_Change
事件的人没有让它处理来自多个单元格的更改。Either rewrite it or make sure to exit the event, whenever more than one cell is selected:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
'rest of the code here
End Sub
推荐阅读
- javascript - Popmotion:弹跳效果
- javascript - 如何从具有不同键的对象中提取 2 个值
- javascript - Javascript更改键的值
- python-3.x - 提高 keras 中对象检测模型的效率
- javascript - 使用firebase登录后页面反复刷新
- php - 如何在codeigniter中按尺寸过滤产品
- flutter - 颤振主题未被覆盖
- python - gensim word2vec 打印日志丢失
- php - 迭代 Traversable 对象时,Xdebug 2.6.1 / PHP 7.2.13 在 PhpStorm 2019.1 EAP 中退出执行
- python - 熊猫加入 table1.x != table2.x