I've seen a lot of posts about this OLE action error, but the difference here is that the macro that I am running isn't importing/exporting any data and isn't triggering actions in any other program (at least not intentionally), which is what I've come to learn is generally the cause. Here is the VBA that generates the error:
Sub DeleteRows()
Dim varResponse As Variant
varResponse = MsgBox("This will permanently delete selected rows. Do you wish to continue?", vbYesNo, "WARNING")
If varResponse <> vbYes Then Exit Sub
Set Rs = Selection
For i = 1 To Selection.Rows.Count
If Range(Rs.Address).EntireRow.Cells(i, 12) <> "d" Then
MsgBox "Selection contains cells that can not be removed. Revise selection.", vbExclamation, "Invalid Selection"
Exit Sub
End If
Next
For Each Worksheet In ActiveWorkbook.Worksheets
Worksheet.Unprotect
Next
ActiveWorkbook.Worksheets("backup_estimate").Cells.Clear
ActiveWorkbook.Worksheets("backup_actual").Cells.Clear
ActiveWorkbook.Worksheets("backup_invoice").Cells.Clear
sourceOld = Selection(1).Row
sourceSize = Selection.Rows.Count
Worksheets("Estimate").Range(Rs.Address).EntireRow.Copy Destination:=Worksheets("backup_estimate").Range("A1")
Worksheets("Actual Cost").Range(Rs.Address).EntireRow.Copy Destination:=Worksheets("backup_actual").Range("A1")
Worksheets("Invoice Tracking").Range(Rs.Address).EntireRow.Copy Destination:=Worksheets("backup_invoice").Range("A1")
Sheets(Array("Estimate", "Actual Cost", "Invoice Tracking")).Select
Range(Rs.Address).EntireRow.Select
Selection.Delete Shift:=x1Up
ActiveSheet.Select
For Each Worksheet In ActiveWorkbook.Worksheets
Worksheet.Protect
Next
End Sub
The purpose of the macro is to delete the same selection of data and rows across 3 of the 6 sheets in this specific workbook, and shift all remaining data up.
When triggering the macro, it will more often than not freeze the instance of excel and give me that error about 10-20 seconds later (it doesn't happen every time). For reference, the "backup_estimate" and other backup sheets are strictly temporary data storage for use by another "undo last action" macro that I have set up.
I do have a single plug-in that I use periodically (blue-beam), but I've encountered this error with the plugins all disabled AND the "ignore other applications that use DDE" option checked (one of the fixes suggested on another post).
x1Up
should bexlUp
You should always useOption Explicit
for exactly this reason. If you disable the add-in and all other code, including any event-handling routines, does it still error? – Tim Williams Nov 28 '18 at 19:25Worksheet
in an Excel project seems like it's asking for trouble. – Comintern Nov 29 '18 at 0:44