Target.count导致溢出错误 [英] Target.count causing an Overflow error
问题描述
我有Worksheet_SelectionChange
功能.在第一行中,我想确定如果选择了多个单元格,则退出.
我写道:
I have Worksheet_SelectionChange
function. In the first line I wanted to condition that if more than 1 cell is selected then exit.
I wrote:
If Target.Cells.Count > 1 Then Exit Sub
但是,当我选择整个工作表时,会出现错误消息: 运行时错误6-溢出"
However, when I select the whole worksheet, I get an error message: "Run time error 6 - Overflow"
Target.Count
似乎无法处理这么大的数字?
It seems like Target.Count
can't handle such large numbers ?
该如何解决?
推荐答案
将Count
替换为CountLarge
.
文档: http://msdn.microsoft.com/zh-cn/library/office/ff196838(v = office.15).aspx
CountLarge
属性在功能上与Count
属性相同,不同之处在于,如果指定的范围具有超过2,147,483,647个单元格(少于2048列),则Count
属性将产生溢出错误.但是,CountLarge
属性最多可以处理工作表的最大大小,即17,179,869,184个单元格.
The
CountLarge
property is functionally the same as theCount
property, except that theCount
property will generate an overflow error if the specified range has more than 2,147,483,647 cells (one less than 2048 columns). TheCountLarge
property, however, can handle ranges up to the maximum size for a worksheet, which is 17,179,869,184 cells.
这篇关于Target.count导致溢出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!