简体   繁体   English

VBA / Excel中行和列范围偏移的最大值是多少?

[英]What is the maximum value for row and column Range offset in VBA/Excel?

I am using microsft excel 2003. I am getting "Application-defined or object-defined error" while executing the following If statement. 我正在使用microsft excel 2003.我在执行以下If语句时收到“应用程序定义或对象定义的错误”。

If Range("MyData").CurrentRegion.Offset(i, 0).Resize(1, 1).Value = Range("MyData").CurrentRegion.Offset(i + 1, 0).Resize(1, 1).Value Then 如果Range(“MyData”)。CurrentRegion.Offset(i,0).Resize(1,1).Value = Range(“MyData”)。CurrentRegion.Offset(i + 1,0).Resize(1,1) .Value然后

The value of i is 58981 when I get this error. 当我收到此错误时,i的值为58981。

Is there any limit on row offset ? 行偏移是否有限制?

Thanks in Advance. 提前致谢。

---Sam ---山姆

excel 2003 worksheets can have a maximum of 65,536 rows (by 256 columns) . excel 2003工作表最多可包含65,536行(256列) i guess your region plus the big offset go over this limit. 我猜你的区域加上大偏移超过了这个限制。

Do the resize before the offset, that way you won't offset a large region so that it exceeds the worksheet size (assuming that the rest of your logic is correct): 在偏移之前调整大小,这样就不会偏移大区域,使其超出工作表大小(假设逻辑的其余部分是正确的):

Range("MyData").CurrentRegion.Resize(1,1).Offset(i,0) 范围( “迈德特”)。CurrentRegion.Resize(1,1).Offset(I,0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM