Excel中的Applescript查找值,然后在同一行中查找另一个值

时间:2012-12-05 20:46:07

标签: excel find applescript lookup

这听起来很简单(我确信它是)但我无法弄清楚如何做到这一点: 我在excel的表中有数据 - 比方说两列:列A包含ID,列B包含电子邮件地址。

我正在寻找一个Applescript,它将打开数据库文件并在一列中查找ID,但返回第二列的值供我稍后在脚本的其余部分使用。

这就是我到目前为止:

set theFile to POSIX path of (choose file with prompt "Choose File to Operate on")
tell application "Microsoft Excel"
activate
open theFile
set searchRange to range ("A1:D2")
try
    set foundRange to find searchRange what "ID1" with match case
    (* do something with the foundRange *)
on error -- not found
    (* do error handling *)
end try
end tell

不确定如何获取第二列并将该值返回到ie。设置为IDEmail?

1 个答案:

答案 0 :(得分:1)

尝试:

tell application "Microsoft Excel"
    set searchRange to range ("A1:A5")
    set foundRange to find searchRange what "ID3" with match case
    set fRow to first row index of foundRange
    set myData to value of range ("B" & fRow as text)
    (* do something with the foundRange *)
end tell

enter image description here