Target.count导致溢出错误 [英] Target.count causing an Overflow error

查看:405
本文介绍了Target.count导致溢出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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 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.

这篇关于Target.count导致溢出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆