gpt4 book ai didi

vba - Target.count 导致溢出错误

转载 作者:行者123 更新时间:2023-12-02 07:06:13 27 4
gpt4 key购买 nike

我有Worksheet_SelectionChange函数。在第一行中,我想要条件是如果选择了超过 1 个单元格,则退出。我写道:

    If Target.Cells.Count > 1 Then Exit Sub

但是,当我选择整个工作表时,我收到一条错误消息:“运行时错误 6 - 溢出”

Target.Count 似乎无法处理这么大的数字?

我能做些什么来解决这个问题?

最佳答案

Count 替换为 CountLarge

文档:http://msdn.microsoft.com/en-us/library/office/ff196838(v=office.15).aspx

The CountLarge property is functionally the same as the Count property, except that the Count property will generate an overflow error if the specified range has more than 2,147,483,647 cells (one less than 2048 columns). The CountLarge property, however, can handle ranges up to the maximum size for a worksheet, which is 17,179,869,184 cells.

关于vba - Target.count 导致溢出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25756467/

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