VBA-填充一个来自许多单独单元的值的数组
我需要一个简单的解决方案,以将一个单元格中指定的单元格的数字输入到一个数组中。
例如,A1充满了特定文本:a3
,b4
,d10
,f1:f45
我需要这些值VBA数组中的单元格 - 我该如何进行代码中的所有内容?我尝试了类似的事情:
Dim x() As Array
x = Range(Range("A1").Value).Value
但是它显然不起作用:)
I need a simple solution for inputing numbers from the cells specified in one cell into an array.
E.g. A1 is filled with particular text: A3
, B4
, D10
, F1:F45
I need values from these cells in the array in VBA - how can I do this withput specifing everything in code? I've tried something like:
Dim x() As Array
x = Range(Range("A1").Value).Value
However it doesn't work apparently :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您希望
array()
才能捕获多个值,例如:关于在数组中添加多个数组的使用,您将需要创建一个复合数组尺寸,该维度尺寸为两个以前的
ubound()
,或简单地redim
参数,并继续添加到新数组中。请参阅有关后者的更多信息。You want the
Array()
to capture multiple values, e.g.:Regarding the use of adding multiple arrays to your array, you will want to create a composite array dimensioned to your two previous
ubound()
, or simplyredim
parameters and keep adding to the new array. See this post for more information on the latter.由于
a3
,b4
,d10
,f1:f45
是不合格的,大概是您想要一个1D数组,您可以使用一个循环:Since
A3
,B4
,D10
,F1:F45
are non-contiguous, and presumably you want a 1D array, you can use a loop: