View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John Wilson John Wilson is offline
external usenet poster
 
Posts: 550
Default Deleting Rows beased on Values

Todd,

Very clunky, but it works...

Sub TestMe()
Dim lRow As Long
lRow = Range("A65536").End(xlUp).Row
Dim x As Integer
Range("A5").Select
For x = 5 To lRow
If IsError(Application.VLookup(ActiveCell.Value,
Worksheets("Sheet2").Range("B3:B97"), 1, False)) Then
ActiveCell.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
End If
ActiveCell.Offset(1, 0).Select
Next x
End Sub

John


"Todd Huttenstine" wrote in message
...
I have values that are on Sheet1 in Range A5:A100. On
Sheet2 I have values that are in Range in B3:B97. I need
a code that will look in the Range on Sheet1 and for each
value in that range, if it does not find that value in the
Range on sheet2, will delete the value in the range on
Sheet1 as well as the entire Row that the value is located
on.

Thank you

Todd