简体   繁体   English

Excel VBA将整个数组从数组数组粘贴到表中

[英]Excel VBA Paste entire row from array of arrays into table

I have an array of arrays. 我有一个数组数组。 Its dimensions can be summed like this: 它的尺寸可以这样总结:
varZaznamyNove(0)(1 to 2, 1 to 20) as shown in the picture. 如图所示, varZaznamyNove(0)(1到2,1到20)

I want to take an entire row and put the data from that row into an Excel table. 我想要整整一行并将该行中的数据放入Excel表中。 For example: 例如:
Range(objListRowBytoveDomyNovy.Range(1, 1), objListRowBytoveDomyNovy.Range(1, 20)) = varZaznamyNove(0)(intPorovnavanyZaznamNovy)

When I attempt to run the line, I get an error: 当我尝试运行该行时,出现错误:

Run time error 9: Subscript out of range. 运行时错误9:下标超出范围。

How can I put entire row from a jagged array, without looping through all of its columns, into an excel table? 如何将锯齿状数组中的整个行(而不遍历所有列)放入excel表中?

Variables used are dimensioned as follows: 所使用的变量的尺寸如下:
objListRowBytoveDomyNovy as lisrow
intPorovnavanyZaznamNovy as integer
varZaznamyNove(0) as variant

Note: 注意:
I don't get an error, when I add second index to the right side of the line, eg: 将第二个索引添加到该行的右侧时,我没有收到错误,例如:
Range(objListRowBytoveDomyNovy.Range(1, 1), objListRowBytoveDomyNovy.Range(1, 20)) = varZaznamyNove(0)(intPorovnavanyZaznamNovy,1)
but this only pust first column into all of the table columns. 但这仅将第一列填充到所有表列中。 That is not desired. 那是不希望的。

Example of the data is shown in picture. 图片中显示了数据示例。 Just to show what I work with (dummy data). 只是为了展示我的工作方式(虚拟数据)。

数据示例

你可以这样做:

Range(objListRowBytoveDomyNovy.Range(1, 1), objListRowBytoveDomyNovy.Range(1, 20)).Value = Application.Index(varZaznamyNove(0), intPorovnavanyZaznamNovy, 0)

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

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