ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   speedy way to set values in a range (https://www.excelbanter.com/excel-programming/297519-speedy-way-set-values-range.html)

emg178

speedy way to set values in a range
 
Hi
I have a list of data that I want to put into a range in excel, and I want to know the fastest way of doing it

I have tried setting each cell value. That is around 0.2 seconds per cell. I have also tried setting an array of the values, and then stepping through the array and putting the value in the range with
range_values(i) = array_values(i
This cuts it down to around 0.15 seconds per cell.

Isn't there a faster way? With 100 cells, this gets pretty slow.

Chip Pearson

speedy way to set values in a range
 
You can assign an entire array to a range with one statement.
E.g.,


Range("A1:A10").Value = Application.Transpose(array_values)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"emg178" wrote in message
...
Hi,
I have a list of data that I want to put into a range in excel,

and I want to know the fastest way of doing it.

I have tried setting each cell value. That is around 0.2

seconds per cell. I have also tried setting an array of the
values, and then stepping through the array and putting the value
in the range with
range_values(i) = array_values(i)
This cuts it down to around 0.15 seconds per cell.

Isn't there a faster way? With 100 cells, this gets pretty

slow.



Alan Beban[_2_]

speedy way to set values in a range
 
emg178 wrote:

Hi,
I have a list of data that I want to put into a range in excel, and I want to know the fastest way of doing it.

I have tried setting each cell value. That is around 0.2 seconds per cell. I have also tried setting an array of the values, and then stepping through the array and putting the value in the range with
range_values(i) = array_values(i)
This cuts it down to around 0.15 seconds per cell.

Isn't there a faster way? With 100 cells, this gets pretty slow.


range_values.Value = array_values

Alan Beban


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com