Very good! If you need some ideas on how to optionally open the other workbook, this is one way:
Sub DeleteRows()
Dim Pth as String, Wkbk As String, ColNum As Long, RwCnt As Long
Application.ScreenUpdating = False
Wkbk = "Other Workbook.xlsx"
Pth = "C:\yourpath\"
On Error GoTo OpenWorkbook
Workbooks(Wkbk).Activate
Continue:
On Error GoTo 0
ColNum = ActiveSheet.UsedRange.Columns.Count + 1
RwCnt = ActiveSheet.UsedRange.Rows.Count
Cells(1, ColNum).Formula = "=If(ISNA(Vlookup(A1," & "'" & Wkbk & "'" & "!DelList,1,False)),"""",True)"
Cells(1, ColNum).AutoFill Range(Cells(1, ColNum), Cells(RwCnt, ColNum))
On Error Resume Next
With Columns(ColNum)
.Copy
.PasteSpecial (xlPasteValues)
.SpecialCells(xlCellTypeConstants, xlLogical).EntireRow.Delete
.Delete
End With
Range("A1").Select
Application.ScreenUpdating = True
MsgBox RwCnt - ActiveSheet.UsedRange.Rows.Count & " rows deleted."
OpenWorkbook:
On Error GoTo FileNotFound
Workbooks.Open Pth & Wkbk
GoTo Continue
FileNotFound:
MsgBox Err.Description
End Sub
Bookmarks