Try this.
Option Explicit
Sub testme()
Dim MstrWks As Worksheet
Dim SecondWks As Worksheet
Dim myCell As Range
Dim MstrRng As Range
Dim SecondRng As Range
Dim DelRng As Range
Dim res As Variant
Dim myFormula As String
Set MstrWks = Workbooks("book1.xls").Worksheets("sheet1")
Set SecondWks = Workbooks("book1.xls").Worksheets("sheet2")
With MstrWks
Set MstrRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With
With SecondWks
Set SecondRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With
For Each myCell In MstrRng.Cells
myFormula = "Match(1,(" & myCell.Address(external:=True) _
& "=" & SecondRng.Address(external:=True) & ")*(" _
& myCell.Offset(0, 1).Address(external:=True) _
& "=" & SecondRng.Offset(0, 1).Address(external:=True) _
& "),0)"
res = Application.Evaluate(myFormula)
If IsError(res) Then
'no match, do nothing
Else
If DelRng Is Nothing Then
Set DelRng = myCell
Else
Set DelRng = Union(myCell, DelRng)
End If
End If
Next myCell
If DelRng Is Nothing Then
'do nothing
Else
Application.Goto DelRng.EntireRow
'DelRng.EntireRow.Delete
End If
End Sub
Change the worksheet names and workbook names in these lines:
Set MstrWks = Workbooks("book1.xls").Worksheets("sheet1")
Set SecondWks = Workbooks("book1.xls").Worksheets("sheet2")
And I do a select the range instead of deleting it--nice for testing:
Application.Goto DelRng.EntireRow
'DelRng.EntireRow.Delete
Delete the .goto line and uncomment the next line after you've verified that it
works ok.