applescript 比较单元格值,然后将一个单元格的值放入另一个单元格中
在数字应用程序表中,我有以下数据
A B C D
user_id login user_id login
2039 Abbott, Rachael Adams, Sue
110 Abbott, Shelby Adamson, Wendy
2910 Abraham, Binu Anderson, Daryl
121 Adams, Sue
122 Adamson, Anne
126 Adamson, Wendy
,我正在尝试编写一个AppleScript,它将...
- 迭代D列中的登录名,
- 以在B列中找到匹配的登录名,
- 并在A列中的行中查找匹配的登录名找到匹配项
- 并将其放入与 D 列中的条目同一行的 C 列中
将 dName 设置为“correlationstudies.numbers” 将 sName 设置为“用户” 将 tName 设置为“表 1” 将登录行设置为 2 将 login_w_id_row 设置为 2 告诉应用程序“Numbers”告诉文档 dName 告诉工作表 sName 告诉表 tName 重复 将登录设置为第 4 列的单元格 login_row 的值 如果登录=“”则退出重复 将 login_w_id_row 设置为 2 重复 将 logincomp 设置为第 2 列的单元格 login_w_id_row 的值 如果logincomp = 登录那么 将第 3 列的单元格 login_row 的值设置为第 1 列的单元格 login_w_id_row 的值 退出重复 结束如果 将login_w_id_row 设置为login_w_id_row + 1 结束重复 将登录行设置为登录行 + 1 结束重复 结束告诉
in a numbers app table i have the following data
A B C D
user_id login user_id login
2039 Abbott, Rachael Adams, Sue
110 Abbott, Shelby Adamson, Wendy
2910 Abraham, Binu Anderson, Daryl
121 Adams, Sue
122 Adamson, Anne
126 Adamson, Wendy
i am trying to write an applescript that will...
- iterate down logins in column D
- to find a matching login in column B
- take the value of the user_id in column A at the row where the match was found
- and place it into column C in the same row as the entry in column D
set dName to "correlationstudies.numbers" set sName to "users" set tName to "Table 1" set login_row to 2 set login_w_id_row to 2 tell application "Numbers" to tell document dName to tell sheet sName to tell table tName repeat set login to value of cell login_row of column 4 if login = "" then exit repeat set login_w_id_row to 2 repeat set logincomp to value of cell login_w_id_row of column 2 if logincomp = login then set value of cell login_row of column 3 to value of cell login_w_id_row of column 1 exit repeat end if set login_w_id_row to login_w_id_row + 1 end repeat set login_row to login_row + 1 end repeat end tell
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于您想要做的事情来说,AppleScript 可能是多余的。在数字文档中,看一下 VLOOKUP 函数,该函数传递一个要查找的值、一组要查找的单元格以及要返回的值的列。我仅通过交换 user_id 和登录列的顺序才能使其工作,但是一旦我将登录名放入 A 列并将 user_id 放入 B 列,设置单元格 C1=VLOOKUP(D2, A2:B7, 2 ) 成功返回 121 。
AppleScript may be superfluous for what you're trying to do. In the numbers documentation, take a look at the VLOOKUP function, which is passed a value to look up, a set of cells to look up in, and the column of the value to return. I got it to work only by swapping the order of the user_id and login columns, but once I put the login in column A and the user_id in column B, setting cell C1=VLOOKUP(D2, A2:B7, 2 ) returned 121 successfully.