Excel setting non contiguous Cell Values

I thought I had asked for help on this topic , the following code works setting the value of cells K2:L2, but I cannot work out if I want to set the values of K2 & M2 on one command line, without doing each cell separately

set strike to "85"
set lastprice to "17.5"
set cnt to "2"
tell application "Microsoft Excel"
	tell active sheet
		set value of range ("K2:L2") to {strike, lastprice}
	end tell
end tell

That’s not possible in Excel.

Each area (i.e. group of contiguous cells, including a single cell) gets assigned the same value, so each of your areas will be assigned {strike, lastprice}. If you are trying that with K2 and M2, then since each area is a single cell, you will just see one value, that of strike.

You will have to use multiple lines or a loop or some other method to assign values to non-contiguous ranges.

1 Like

Thanks learn something every day.Main problem resolved thank again.