Excel cell values query...

Hi Everyone,

Please can someone point me in the right direction with this query.

I’ve done a few projects with Excel AS however this little query has me baffled at the moment.

I have a range of values in a column in Excel, all numerical 6 digit numbers.
Here’s a little snippet of what I’m looking at.

tell application "Microsoft Excel"
	activate
	set thisVal to string value of cell ("I2")
	
	set thisList to value of range ("I2:I90")
end tell

If I get the content of a cell individually it returns it correctly.
However, if I use to the second method I get values like this:-

{4.00187E+5}, {4.00195E+5}, {4.00195E+5}

I’ve tried quite a few versions on a theme but still I get the above. I’ve also tried different cell formats. I’ve used both of the methods before and they’ve worked fine?

Please can someone show me how I should be selecting the range to get it into a list with all the content correct?

Thanks in advance.

Regards,

Nick

P.S. I’m using Excel 2004 on 10.5.8.

What do you mean by correct content?
Do you want a list like {1.23456E+5, 2.46912E+5}
If so, a loop is needed.

If you want integers, I don’t know why since they calculate like reals.

tell application "Microsoft Excel"
	set integerList to {}
	repeat with i from 1 to 3
		copy {(value of (cell i of range "a1:a3") as integer)} to end of integerList
	end repeat
	
	set realList to {}
	repeat with i from 1 to 3
		copy value of (cell i of range "a1:a3") to end of realList
	end repeat
		
	set testList to {}
	repeat with i from 1 to 3
		copy ((item i of realList) - (item i of integerList)) to end of testList
	end repeat
	testList -- returns {0.0, 0.0, 0.0}
end tell

Thanks for the help and apologies for the lack of information.

The numbers should be:-
400187
400195
400195 etc…

But what I’m getting is :-
{4.00187E+5}, {4.00195E+5}, {4.00195E+5}

I’ll try implementing the fix you’ve listed and see if that does it.

Thanks again for the help.

Regards,

Nick

use formula instead of value


tell application "Microsoft Excel"
	set thisList to formula of range ("I2:I90")
end tell

Thanks for your speedy reply Stefan.

As usual it was spot on. :slight_smile:

Regards,

Nick