简体   繁体   中英

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.

I want to take an entire row and put the data from that row into an Excel table. 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.

How can I put entire row from a jagged array, without looping through all of its columns, into an excel table?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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