2014-10-09 188 views
0

我是苹果脚本的新用户,希望得到一些帮助。AppleScript Excel单元格搜索和替换其他单元格

我想使用Applescript和Excel来自动化我的工作,以便它可以更快。

经过applescript重复数据删除记录后,我希望能够检查列(列A),如果它的数值超过100。如果是,我想另一列(列B)在同一行将被粘贴文本“已注册”。

下面,我想自动筛选和删除其B栏具有文本“正常”

预先感谢您的帮助任何行。

以下是我用于删除列和推断记录的代码。

更新的问题截止日期2014年10月11日 1)我需要在文本的最后一列中的单元格中选择一行。只要感觉不是SG。该行应选择 2)我需要能够复制该行并将其移动到最后一行(这是一个艰难的,因为我看到从这个逻辑的永无止境的循环 - 将结束重复停止这个循环?) 3)我需要从列表中删除所有空白。 4)我需要从上到下按顺序完成1和2,这样他们的ID就不会混乱起来。

2014年10月更新于11 ShooTerko的剧本

tell application "Finder" 
activate 
open document file "orders.csv" of folder "Input" of folder "Automation" of folder "AAS Orders" of folder "A A Selections 1st June" of folder "Adlina A. Pte Ltd(NEW)" of folder "Fizzy Pop Pte Ltd" of folder "Dropbox (Fizzy Pop)" of folder "zayedtalib" of folder "Users" of startup disk 

tell application "Microsoft Excel" 
    tell active sheet of active workbook 
     set myColumn to range "B:K" 
     delete myColumn 
     set myColumn to range "C:D" 
     delete myColumn 
     set myColumn to range "D:V" 
     delete myColumn 
     set myColumn to range "F:G" 
     delete myColumn 
     set myColumn to range "K:AA" 
     delete myColumn 
    end tell 
end tell 
tell application "Microsoft Excel" 
    set maxRow to count of rows of used range of active sheet 
    repeat with currentRow from maxRow to 2 by -1 

     set currVal to (value of row currentRow of column 1 of active sheet) 

     set nextVal to (value of row (currentRow - 1) of column 1 of active sheet) 

     if currVal = nextVal then 
      delete range (row currentRow) of active sheet 
     end if 
    end repeat 
end tell 
tell application "Microsoft Excel" 
    autofilter range range "C:C" field "1" criteria1 "Normal >14days" 
end tell 
tell application "Microsoft Excel" 
    if exists active sheet then 
     set usedRows to every row of (used range of active sheet) whose value is not missing value 

     -- Walk through the used rows 
     -- Set values of column B to "Registered" if value of column A is greater than 100 
     repeat with aRow in usedRows 
      if (value of row (first row index of aRow) of column ((first column index of aRow) + 1) is greater than 100) then 
       set value of row (first row index of aRow) of column ((first column index of aRow) + 2) to "Registered" 
      end if 
     end repeat 

     -- Loop from last rows to first rows to easily delete rows 
     -- Delete all rows containing "Normal" in column B 
     repeat with aRow in (reverse of usedRows) 
      if (value of row (first row index of aRow) of column ((first column index of aRow) + 1) = "Normal") then 
       delete aRow 
      end if 
     end repeat 
    end if 
end tell 
tell application "Microsoft Excel" 
    autofilter range range "C:C" field "1" criteria1 "Registered" 
end tell 

末告诉

回答

0

我想这和它的工作描述:

tell application "Microsoft Excel" 
    if exists active sheet then 
     set usedRows to every row of (used range of active sheet) whose value is not missing value 

     -- Walk through the used rows 
     -- Set values of column B to "Registered" if value of column A is greater than 100 
     repeat with aRow in usedRows 
      if (value of row (first row index of aRow) of column (first column index of aRow) is greater than 100) then 
       set value of row (first row index of aRow) of column ((first column index of aRow) + 1) to "Registered" 
      end if 
     end repeat 

     -- Loop from last rows to first rows to easily delete rows 
     -- Delete all rows containing "Normal" in column B 
     repeat with aRow in (reverse of usedRows) 
      if (value of row (first row index of aRow) of column ((first column index of aRow) + 1) = "Normal") then 
       delete aRow 
      end if 
     end repeat 
    end if 
end tell 
+0

嗨ShooTerko, 谢谢你这么多你的解决方案 您的建议绝对有效。 我已经为我的工作流程添加了代码以及其他一些代码,现在我错过了最后一部分,正如我在更新后的问题中指出的那样。 希望你能够提供帮助。 我已更新我的问题 – 2014-10-10 19:39:46

相关问题