非常感谢你的帮助。
我有一个电子表格,其中列出了产品的行和产品详情。
我正在尝试使用Excel来查找A列中的产品代码,然后将已存在于剪贴板中的相应值粘贴到C列中。我使用以下脚本:
tell application "Microsoft Excel"
set searchRange to range ("A1:A5")
set foundRange to find searchRange what "AM100" with match case
set fRow to first row index of foundRange
set myData to value of range ("B" & fRow as text)
set theClip to the clipboard as text
end tell
我似乎无法在找到产品代码的同一行的C列中进行粘贴。
请帮忙......
非常感谢 达里尔
答案 0 :(得分:0)
尝试使用此解决方案。
它使用剪贴板文本查找并替换搜索词的每个实例。
tell application "Microsoft Excel"
set search_range to range "A:A" -- look in column A
set search_term to "AM100"
set found_range to ""
set counter to 0
try
set found_range to find search_range what search_term look at whole with match case
on error
log ("No matches found")
end try
if (found_range is not "") then
set first_cell_address to (get address of the cells of found_range)
log ("first_cell_address = " & first_cell_address)
repeat while true
set cur_row to the first row index of found_range
set mod_cell to cell cur_row of column 3 -- the same row in C column
set value of mod_cell to (the clipboard as text)
set counter to counter + 1
-- Now look for next result
set found_range to find next search_range after found_range
set cell_address to (get address of the cells of found_range)
if (cell_address = first_cell_address) then -- have looped around so we are finished!
exit repeat
end if
end repeat
end if
log ("found " & counter & " items")
end tell
Applescript-Excel可能会令人困惑,但至少它仍然受到支持(*咳嗽*苹果)