Hi Steve
No idea what I'm screwing up here! Just to be clear, the values I want
to delete are on sheet2 column J
the script looks like:
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("J1:J" & LastRow)
For Each MyCell In MyRng
Set FoundCell = Worksheets("Sheet2").Cells _
.Find(What:=MyCell, LookAt:=xlWhole)
If Not FoundCell Is Nothing Then
FoundCell.EntireRow.Delete
End If
Next MyCell
End Sub
when I run it I get a subscript out of range error.
All you need to do is change the following line to reflect which sheet
you are running the "FIND" on like so
Set FoundCell = Worksheets("Sheet2").Cells _
.Find(What:=MyCell, LookAt:=xlWhole)
The code already takes the list to search for from sheet3. i hope
this makes it a little clearer for you but if you have any more
problems with the code let me know and i will comment it for you.
Steve- Hide quoted text -
- Show quoted text -