我是AppleScript的新手,几乎已经完成了一个脚本来整理一个电子表格并将其格式化以导入到FileMaker数据库中。该电子表格是捐赠者的月度声明,我只想从中提取捐款。在捐赠记录下面,我需要删除一些导入列中的一些会计信息,以便清理导入数据。
这是完整的脚本:
tell application "Microsoft Excel"
activate
set theWorkbook to open workbook workbook file name "File Path"
--Open the file that contains the DonorId for all Donors
set theWorkbook to open workbook workbook file name "File Path"
--Open the Monthly Transaction Report
set myrange_1 to range ("A1:E4")
delete myrange_1
tell worksheet "Transaction Report" of active workbook
set value of cell "A1" to "DonorID"
autofit columns of range "A1:A100"
set lastRow to ((count of rows of used range of active sheet) - 13)
set myRange_2 to range ("A2:A" & lastRow) of active sheet
set formula of myRange_2 to "=VLOOKUP($C$2:$C$100,'[Donor ID.xlsx]Sheet1'!$A$1:$B$60, 2, FALSE)"
set value of cell "F1" to "Donation Method"
set myRange_3 to range ("F2:F" & lastRow) of active sheet
set formula of myRange_3 to "=IF(D2=\"\",\"Check\", IF(D2=\"CC\",\"Credit Card\", IF(ISNUMBER(SEARCH(\"E\",D2)),\"EFT\",\"#N/A\")))"
try
set myRange_2 to find what "#N/A" look at whole with match case
on error
log ("No matches found")
end try
if (myRange_2 is not "") then
display dialog "New Donor @ " & (get address of the cells of myRange_2)
end if
set myRange_4 to range ("A" & lastRow + 1)
set myRange_5 to range ("F" & lastRow + 13)
end tell
end tell
一切都很好,除了我找不到使用变量来设置要删除的单元格范围的方法。此范围是从lastRow +1到lastRow +13的第1列到第5列。我尝试根据" myRange_4:myRange_5"设置一个范围,但我无法让它工作。任何帮助将不胜感激!
答案 0 :(得分:1)
这是解决方案
set rangeToDelete to range ("A" & (lastRow + 1)) & “:F” & ( lastRow + 13)