Paste 2x2 array
Posted on 2011-03-21
Hello-- I am retrieving data from a database using embedded sql code in VBA and storing it in a 2x2 array. I need to paste it all into spreadsheet and right now am just doing it with a nested for-loop:
For i = 0 To UBound(dbdata,2)
For j = 0 To UBound(dbdata)
ActiveSheet.Cells(i+1,j+1).Value = dbdata(j,i)
But it is a tremendous array and it's a pretty long run-time to insert each value in the array into the spreadsheet one by one. Is there a way to just paste the entire array into the spreadsheet in one fowl swoop, ie something along the lines of dbdata.paste [with dbdata(1,1) at ActiveSheet.Cells(1,1)]?