在VBA中的工作表中指定Excel范围 [英] Specify an Excel range across sheets in VBA
问题描述
在VBA中,为什么会失败?
In VBA, why does the following fail?
Dim rng as Range
rng = Range(Sheet1:Sheet3! A1)
它会抛出HRESULT异常。有没有另外一种方式来构建这个范围在VBA?请注意,您可以输入工作表函数,如= SUM(Sheet1:Sheet3!A1),它可以正常工作。
It throws an HRESULT exception. Is there another way to construct this range in VBA? Note that you can enter a worksheet function like =SUM(Sheet1:Sheet3!A1) and it works fine.
推荐答案
strong>范围对象仅限于一个工作表。毕竟,它只能有一个父级。
A Range object is limited to only one worksheet. After all, it can have only a single parent.
= SUM()函数可以对一组范围进行操作。
The =SUM() function can operate on a group of ranges. (this is true for many worksheet functions)
编辑#1
自Janauary以来我一直在寻找解决方案:
I have been searching for a solution since Janauary:
。
我一直在使用一系列范围。不是很好的解决方案。
I have been using an array of ranges. Not a very good solution.
这篇关于在VBA中的工作表中指定Excel范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!