View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] wrethams@gmail.com is offline
external usenet poster
 
Posts: 17
Default deleting rows if they contain a value held in a separate list

Steve - sorry for being thick here

My column A that I want to delete the rows from is on sheet2. The list
of codes I'm cross checking against is on sheet3.

How do I tweak the code to reflect this?

On Apr 4, 3:53 pm, Incidental wrote:
Hi Wreth

One way to do it in code would be

Option Explicit
Dim MyCell, MyRng As Range
Dim FoundCell As Range
Dim LastRow As Integer
Private Sub CommandButton1_Click()

Worksheets("Sheet3").Activate

LastRow = [A65535].End(xlUp).Row

Set MyRng = Range("A1:A" & LastRow)

For Each MyCell In MyRng

Set FoundCell = Worksheets("Sheet1").Cells _
.Find(What:=MyCell, LookAt:=xlWhole)

If Not FoundCell Is Nothing Then

FoundCell.EntireRow.Delete

End If

Next MyCell

End Sub

I hope this helps you out.

Steve