I want be able to delete all rows in Sheet1 inf the names in column A do not match the names in the named range nameList. I have worked out the following code, by I can't get it to work. I keep getting Runtime error 1004.
Private Sub Test() Dim namedRng As Range Dim rng As Range Dim c As Variant Set namedRng = Range("nameList") Set rng = Range("A2:A" & Sheet1.Cells(Rows.Count, "A").End(xlUp)) For Each c In rng If WorksheetFunction.CountIf(namedRng, c.Value) = 0 Then c.EntireRow.Delete End If Next End Sub
I can't figure out what I am doing wrong here.
I also posted on http://www.mrexcel.com/forum/e…l-basic-applications.html