VBA Array output to Excel sheet

gavs73

Board Regular
Joined
Apr 22, 2008
Messages
138
Hi

I have an Array which has been populated with data from several Sheets, I want to output this into a sheet as one block of data, currently I'm going line by line, but is there a quicker way ?

Thanks in advance for your help.

Gav



pivnum = 0
cell = 4
Do
Range("A" & cell) = pivotarray(0, pivnum)
Range("B" & cell) = pivotarray(1, pivnum)
Range("C" & cell) = pivotarray(2, pivnum)
Range("D" & cell) = pivotarray(3, pivnum)
Range("E" & cell) = pivotarray(4, pivnum)
Range("F" & cell) = pivotarray(5, pivnum)

pivnum = pivnum + 1
cell = cell + 1
Loop Until pivotarray(0, pivnum) = Empty
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi Gav,

I may be mis-reading, but is pivotarray size the same as the destination range, save that it is transposed?

Mark
 
Upvote 0
Hi

The array size is variable, but the output into the sheet would be the entire array.

Thanks
Gav
 
Upvote 0
Okay, a blind stab, but if both dimensions in pivotarray are 0-based, maybe:
Rich (BB code):
    Range("A4").Resize(UBound(pivotarray, 2) + 1, _
                       UBound(pivotarray, 1) + 1).Value _
                            = Application.Transpose(pivotarray)
Does that work?

Mark
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top