Excel 2010中VBA中行和列偏移量的最大值是多少?

编程入门 行业动态 更新时间:2024-10-19 12:43:52
本文介绍了Excel 2010中VBA中行和列偏移量的最大值是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道一个类似的问题已经在这里回答:

但是,该错误似乎与Excel 2003中工作表中的行数相关。由于我运行的是Excel 2010(拥有65,536行),我不认为我的错误是相关的到我的工作表大小。

这是给我的代码行运行时错误'6'溢出:

+ code> Range(OutputStart)。Offset(1 +(iCounter1 - 1)* iDataPoints * 26 + iCounter2 * iDataPoints,0).PasteSpecial Paste:= xlPasteValues,Operation:= xlNone,SkipBlanks:= False,Transpose:= True

iCounter1是一个整数,其值为13 iDataPoints是一个整数,其值为103 icounter2是一个整数,其值为7

行偏移计算的结果为32,858,表示整数数据类型问题。行偏移量是否限于整数数据类型?如果是这样,有没有办法将该限制改为Long(或另一种数据类型)?

感谢您提供任何帮助!

解决方案

不要使用整数:它们是16位有符号值;他们的范围是-32768到32767.这就是为什么你得到溢出。

使用长而不是。

I know a similar question has been answered here:

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

However, that error seemed to be related to the number of rows in the worksheet in Excel 2003. Since I am running Excel 2010 (with 65,536 rows), I don't think my error is related to my worksheet size.

Here is the line of code that is giving me Run-time error '6' Overflow:

Range("OutputStart").Offset(1 + (iCounter1 - 1) * iDataPoints * 26 + iCounter2 * iDataPoints, 0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True

iCounter1 is an integer and its value is 13 iDataPoints is an integer and its value is 103 icounter2 is an integer and its value is 7

The result of the row offset calculation is 32,858, which indicates an Integer data type issue. Is the row offset limited to Integer data types? If so, is there any way to change that limitation to Long (or another data type)?

Thanks for any help you can provide!

Will

解决方案

Don't use Integer: they are 16 bit signed values; their range is -32768 to 32767. That is why you're getting the overflows.

Use a Long instead.

更多推荐

Excel 2010中VBA中行和列偏移量的最大值是多少?

本文发布于:2023-11-12 04:04:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580470.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最大值   中行   偏移量   Excel   VBA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!