Hi,
I am trying to take a set of values from a spreadsheet and go from memory to the spreadsheet and spreadsheet to memory. Suppose we take an already made array of values...lets start with a one dimensional array of like 20 elements. We'll call it myarray(1 to 20). Is there any way to put the values from myarray(1) to myarray(20) from memory to the spreadsheet, and the reverse going from row A1 to A20 and put those values into memory. The only thing is that i wanted to do this without using a loop that goes:
dim x as integer
dim myarray(1 to 20) as double
for i = 1 to 20
worksheets(1).range("A" & i).value = myarray(i)
next i
this method is a simple solution, but in my question, i am asking if there is any way to do something like
worksheets(1).range("A1:A20").values = myarray
or something like the reverse where you go
myarray = worksheets(1).range("A1:A20").values
this code would do the whole array in one big statement but i just dont know the syntax of it. Also, this method would be much faster than the loop version earlier. Anyone got any ideas?
thanks
I am trying to take a set of values from a spreadsheet and go from memory to the spreadsheet and spreadsheet to memory. Suppose we take an already made array of values...lets start with a one dimensional array of like 20 elements. We'll call it myarray(1 to 20). Is there any way to put the values from myarray(1) to myarray(20) from memory to the spreadsheet, and the reverse going from row A1 to A20 and put those values into memory. The only thing is that i wanted to do this without using a loop that goes:
dim x as integer
dim myarray(1 to 20) as double
for i = 1 to 20
worksheets(1).range("A" & i).value = myarray(i)
next i
this method is a simple solution, but in my question, i am asking if there is any way to do something like
worksheets(1).range("A1:A20").values = myarray
or something like the reverse where you go
myarray = worksheets(1).range("A1:A20").values
this code would do the whole array in one big statement but i just dont know the syntax of it. Also, this method would be much faster than the loop version earlier. Anyone got any ideas?
thanks