Help required with small Excel niggle please...

Hi there,

Over the weekend I was doing some work on a script that pulls data from Excel and, after some formatting, populates a named text box in Quark. Whilst writing the script I had a slight problem with some of the values from Excel.

I was using the following code to get a list of values from Excel:-

tell application "Microsoft Excel"	
	set startRow to 1
	set endRow to 70
	set code_list to value of range ("A" & startRow & ":A" & endRow)
end tell

Column A consists of numbers from 1 to 70 however when I populate the relevant text box, in Quark, I find that all the values from column A have a ‘.0’ on the end e.g. 15.0, 16.0, 17.0 etc.

Please can someone tell me why this might be?

I’ve tried a number of variations on a theme but as yet haven’t managed to sort it, I’ve just worked round it.

Thanks in advance,

Nick

Hi Nick,

value returns a real number, if the contents of the cell is a number.
The easiest way to coerce the number class is a repeat loop, which also corrects the double nested list

tell application "Microsoft Excel"
	set startRow to 1
	set endRow to 70
	set code_list to value of range ("A" & startRow & ":A" & endRow)
	repeat with i in code_list
		set contents of i to item 1 of i as integer
	end repeat
end tell

Hi Stefan,

Thanks for the help and the code.
It works perfectly. :slight_smile:

Regards,

Nick