Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AppleScript&;Excel:基于变量的设置范围_Excel_Macos_Applescript - Fatal编程技术网

AppleScript&;Excel:基于变量的设置范围

AppleScript&;Excel:基于变量的设置范围,excel,macos,applescript,Excel,Macos,Applescript,我是一名AppleScript新手,几乎已经完成了编写一个脚本来制作电子表格,并将其格式化以导入FileMaker数据库。这个电子表格是捐赠者的月度报表,我只想从中提取捐款。在捐赠记录下面,我的一些导入列中有一些会计信息,我需要删除这些信息,以便获得干净的数据导入 以下是完整的脚本: tell application "Microsoft Excel" activate set theWorkbook to open workbook workbook file name "File Path"

我是一名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                                                                        
一切都很好,除了我找不到使用变量设置要删除的单元格范围的方法。此范围从第1列到第5列,从lastRow+1到lastRow+13。我试着根据“myRange_4:myRange_5”设置一个范围,但我无法让它工作。任何帮助都将不胜感激

这是解决方案

set rangeToDelete to range ("A" & (lastRow + 1)) & “:F” & ( lastRow + 13)

脚本中还有其他代码可以发布到您的问题中吗?:)刚刚编辑并发布了整个脚本。因此,为了澄清,您现在想要选择A.lastRow+1和F.lastRow+13之间的所有列(以及相应的行),但没有选择该范围,因为此时仅选择A列和F列?是的,我想要选择A.lastRow+1和F.lastRow+13。当我尝试将myRange_6设置为“myRange_4:myRange_5”,然后删除myRange_6时,会收到一条错误消息。如下所示:
将rangeToDelete设置为range(“A”&(lastRow+1))&“:F”&(lastRow+13)