applescript 比较单元格值,然后将一个单元格的值放到另一个单元格中 [英] applescript to compare cell values and then place the value of one cell into another

查看:68
本文介绍了applescript 比较单元格值,然后将一个单元格的值放到另一个单元格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在数字应用表中,我有以下数据

 A B C Duser_id 登录 user_id 登录2039 雅培、瑞秋·亚当斯、苏110 雅培、谢尔比·亚当森、温迪2910 亚伯拉罕、比努·安德森、达里尔121 亚当斯,苏122 亚当森,安妮126 亚当森,温迪

我正在尝试编写一个可以...

  1. 迭代 D 列中的登录
  2. 在 B 列中查找匹配的登录名
  3. 在找到匹配的行的 A 列中获取 user_id 的值
  4. 并将其放入与 D 列中的条目同一行的 C 列

<块引用>

将 dName 设置为correlationstudies.numbers"将 sName 设置为用户"将 tName 设置为表 1"将 login_row 设置为 2将 login_w_id_row 设置为 2告诉应用程序数字"告诉文档 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结束重复将 login_row 设置为 login_row + 1结束重复结束告诉

解决方案

AppleScript 对于您正在尝试执行的操作可能是多余的.在数字文档中,查看 VLOOKUP 函数,该函数传递了一个要查找的值、一组要查找的单元格以及要返回的值的列.我只是通过交换 user_id 和 login 列的顺序来让它工作,但是一旦我将登录名放在 A 列中并将 user_id 放在 B 列中,设置单元格 C1=VLOOKUP(D2, A2:B7, 2 ) 成功返回 121.

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...

  1. iterate down logins in column D
  2. to find a matching login in column B
  3. take the value of the user_id in column A at the row where the match was found
  4. 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

解决方案

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.

这篇关于applescript 比较单元格值,然后将一个单元格的值放到另一个单元格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆