Hi,
I’m trying to write a script that searches one column (column G) for a code number and then pastes a value (“Yes”) in to the cell in column O of the row the code number is in.
I’m just trying to get it to work with one code for the moment. Once I get that right I intend to pass a range of codes from a text file to the script.
Sor far I can find the data and get the row is appears in. What I can’t work out is how to select column O of the same row and insert the work “Yes” - I’m new to Applescript.
Any help would be greatly appreciated.
This is what I’ve done so far:
tell application "Microsoft Excel"
activate
select worksheet "MASTER LIST"
set UPC to (find (range "G:G") what "25218672122") --
set selectRow to get first row index of UPC
end tell
Getting there:
set thisFile to choose file with prompt "Choose your text file:"
tell application "TextWrangler"
open thisFile
set eachLIne to get (every line in window 1) as list
close window 1
end tell
repeat with eachCode in eachLIne
tell application "Microsoft Excel"
activate
select worksheet "MASTER LIST"
set UPC to (find (range "G:G") what eachCode) --
set selectRow to get first row index of UPC
set fillCell to "$" & "O" & "$" & selectRow
set cellValue to (get value of cell fillCell) as string
set the value of cell fillCell to "Worked"
end tell
end repeat
I’m getting a few errors where by AppleScript say “doesn’t understand the range G:G” this is what happens if the code does not exist. Can anyone suggest an error handling routine?
That’s much better - thanks
One final question, how would i use the 'find next" to change all cell with the same code. The number of the cells with the same code varies.