Getting selected values from excel and separating them


I am making a script to help print labels from data in excel the first step is getting the data from excel and separating it and getting the data from cells that are not next to each other.

For example in column A there is an Order Number then in B, C, D there is just data that isn’t needed for the labels then in E there is the product code and in F, G or H there is the amount of the product needed depending on the size.

I have tried using CMD and select and getting the script to return the values but it only gets the value of the first selected cell.

Here is an example of the data that would be fetched:
Order No.>Product Code>amount
1234 AA-BB-CC-D 15

I need the user to be able to select the information needed as the pending sheet changes every day so the information everyday is on different rows.

and I want to be able to separate the returned information for example:

set a to 1234 
set b to AA-BB-CC-D
set c to 15

and then separate the value of “b”

set b1 to AA
set b2 to BB
set b3 to CC

this is because the majority of the product code relays to the product description which is also the label I want to print out.

here is the code that I have which returns the value of the cells at the moment but it only works if the cells are next to each other:

tell application "Microsoft Excel"
	set c to value of selection
end tell
return c

I know it is a tall order for the OP but any help will be greatly appreciated!


I have set c to cells of selection which returns the cell letters and numbers but when I try to return the value of those I get the error

but only one of those cells is correct “K23” the other values should be F23 and A23 anybody know why this is?

Thanks again,

Hi bruce00j,

Here’s an example of parsing the “b” line:

set b to "AA-BB-CC-D"
set tids to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"-"}
set the_list to text items 1 thru 3 of b
set AppleScript's text item delimiters to tids
return the_list


Thanks for the response.

I have started on something since I posted this topic.

I have used variables checking to see if it contains certain bits of text i.e.

set B to "AA-BB-CC-D"
if B contains "AA" then
set B1 to "AA"


Although I might use your way as most of the sections have about 5 different verities to go into it.

I have made a very long applescript which gets the job done but I think its a bit clunky and it requires more user input that I would like for selecting the data using dialogue boxes and fetching data and I would like the user just select the row and gather certain information from that so it would grab data from column A, F and the G-K where there would be one piece of information in G-K but can be on G, H, I, J and K.

So for example if I wanted the data off row 15 how would I get those cells data without having to grab it individually via dialogue boxes asking the user to select the cells.

is there anyway of doing this?