Populating a range in Excel with values from a list

More Excel questions…

Ok, I figured out how to take a list of values ie {“1”, “2”, “3”, “4”} and set the contents of a row ie (A1:D1) to those values. Doing so gets you a row of values one cell after another horizontally:

set myList to {"1", "2", "3", "4"}
set value of range "A1:D1" to myList

This gets your list in one horizontal row, one value per cell:
1 2 3 4

I then decided to take the same list and apply it to a range with both rows and columns, so I tried changing the above range to (A1:B2):

set myList to {"1", "2", "3", "4"}
set value of range "A1:B2" to myList

This still only gets me a horizontal row in excel, it just truncates the end of the list, and doesn’t move down to the next row even though I defined that within the range value:
1 2

So my question is I would like to take a similar list of values, and set the contents of a range of both rows and columns ie (A1:B2) to those values so you end up with the following in Excel where A1=1, B1=2, A2=3, B2=4:
1 2
3 4

How would one do this? Do I have to format the list differently?

Hello there:

The only way I have ever been able to solve this issue is to use a counter repeat:

tell application "Microsoft Excel"
	set myList to {"1", "2", "3", "4"}
	set item_Count to (count myList)
	repeat with z from 1 to item_Count
		set value of cell z in range "A1:B2" to item z of myList
	end repeat
end tell

Good luck.

Thanks guys. The both answers worked as advertised, but I use Jacques version just to keep it clean (I have a very small range). If I ever need to populate a larger range, I think I’ll give Craig’s example a go.

Thanks again!