I am new to AS and I wrote this Script in order to check if values from a range in a workbook can be found in the third row of another workbook.
tell application "Microsoft Excel"
activate
set data_file to "data sectoriels.xls"
set indexdatasheet to "DS"
set file_name to "signal CT.xls"
set indexsheet to "Index Data"
open data_file
activate object sheet indexdatasheet
open file_name
activate object sheet indexsheet
set mix_sector_index to range "MIX_SECTOR"
display dialog (count of cells in mix_sector_index) / 2
repeat with i from 1 to 11 by 2
set oneCell to cell i of mix_sector_index
if length of (value of oneCell as text) = 0 then
exit repeat
else
display dialog "Found in " & (get address of oneCell) & " " & (value of oneCell as text)
set search_sector_code to value of oneCell
activate object workbook data_file
activate object sheet indexdatasheet of workbook data_file
repeat with j from 1 to count of cells in row 3
display dialog (value of cell i of row 3 of sheet indexdatasheet as text)
if (value of cell i of row 3 of sheet indexdatasheet) = search_sector_code then
display dialog "bingo !" & (value of search_sector_code)
activate workbook file_name
exit repeat
end if
end repeat
end if
end repeat
end tell
Unfotunately, this script stops on “activate object sheet indexdatasheet of workbook data_file”.
I would be grateful if anyone can help me with this problem.
Pongocito