我对整个事情和网站有点陌生,最近遇到了我无法解决的代码错误。我的目标是让我的宏能够将包含短语“分包商:”的任何单元格从 A 列剪切到 L 列偏移的单元格(1,11)。我的代码允许它这样做,但即使我得到了我想要的结果,但会提供错误 91。
代码:
Sub SiteAccess()
Dim mySheet As Worksheet, myOtherSheet As Worksheet, myBook As Workbook 'Define your workbooks and worksheets as variables
Set myBook = Excel.ActiveWorkbook
Set mySheet = myBook.Sheets("SiteAccessReports")
Dim cc As Excel.Range, ee As Long
Do
For Each cc In Range("A1:A30000") 'Or whatever yours is
If cc.Value Like "*SUBCONTRACTOR : *" Then
cc.Cut Destination:=cc.Offset(1, 11)
For ee = mySheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count - 1 To ActiveSheet.UsedRange.Row Step -1
If Cells(ee, 1) = 0 _
Then Cells(ee, 1).EntireRow.Delete
Next ee
Exit For
End If
Next
Loop Until cc.Value = "***END OF REPORT*** " 'Error Line
End Sub
感谢我能得到的任何帮助。