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

瘦欲@ 提交于 2019-12-02 11:12:31

问题


I am using microsft excel 2003. I am getting "Application-defined or object-defined error" while executing the following If statement.

If Range("MyData").CurrentRegion.Offset(i, 0).Resize(1, 1).Value = Range("MyData").CurrentRegion.Offset(i + 1, 0).Resize(1, 1).Value Then

The value of i is 58981 when I get this error.

Is there any limit on row offset ?

Thanks in Advance.

---Sam


回答1:


excel 2003 worksheets can have a maximum of 65,536 rows (by 256 columns). i guess your region plus the big offset go over this limit.




回答2:


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)



来源:https://stackoverflow.com/questions/2146283/what-is-the-maximum-value-for-row-and-column-range-offset-in-vba-excel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!