通过工作表自动化循环代码时发生错误异常

时间:2019-08-21 20:40:31

标签: excel vba

我正在通过30-50个标签的工作表循环以下代码。我不断收到错误“自动化错误,发生异常”。当我单击“确定”时,excel变得无响应,程序关闭。为什么会这样呢?

Sub Step19MatchStrike()
    Dim ws As Worksheet
    Dim LastRowColumnA As Long
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Index > 3 Then
            LastRowColumnA = ws.Cells(Rows.Count, 1).End(xlUp).Row
            ws.Range("AA1").Value = "Strike Determination"
            ws.Range("AA2").FormulaArray = "=IF((MATCH(E2,INDEX(Sheet3,(MATCH(A2,INDEX(Sheet3,,1),0)),5),0))>0,""To Keep"",""To Delete"")"
            ws.Range("AA2").Copy ws.Range("AA3:AA" & LastRowColumnA)
            ws.Columns(27).Value = ws.Columns(27).Value
        End If
    Next ws
End Sub

0 个答案:

没有答案