Question : How do I find and delete data in excel using a list of data?

I have a list of Serial numbers in one workbook (Data), that I need to find in another workbook (Master). If the number is found...than that row needs to be deleted. A macro would be great for this if possible.

Answer : How do I find and delete data in excel using a list of data?

Hi Jimi,

Try this.
Save the attached Code into a new Module on your DATA file.
Save the MASTER file somewhere and put that file location into Line 6 (Const MasterName = "C:\Test\EE\Test-Find-and-Delete-Master.xls")

Save and Close the MASTER file.

Run the Macro from the DATA file.

it took approx 30 seconds on my comp...i'm sure it could speed up a bit...i'm not sure how though
 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
Option Explicit 
Sub RemoveRows()
Dim c, d, e, i As Integer
Dim DudRange As Range
Const MasterName = "C:\Test\EE\Test-Find-and-Delete-Master.xls"
Dim wb
Set DudRange = ActiveSheet.UsedRange
Set wb = Workbooks.Open(Filename:=MasterName, UpdateLinks:=False)
Dim RowsToDelete()
ReDim RowsToDelete(1 To wb.Sheets(1).UsedRange.Rows.Count)
Dim RowCheck
Dim DeletbleRows As String 
'Performance
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual 
For c = wb.Sheets(1).UsedRange.Rows.Count To 1 Step -1
  For Each e In wb.Sheets(1).UsedRange.Columns
    For Each d In DudRange
      If d.Value <> "" And d.Value = wb.Sheets(1).Cells(c, e.Column) Then
      RowCheck = True
      End If
    Next d
  Next e
  If RowCheck Then
  wb.Sheets(1).Rows(c & ":" & c).Delete
  RowCheck = False
  End If
Next c 
'Performance
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlAutomatic 
With wb
  .Save
  .Close
End With
End Sub
 
Test DATA with Bromy's Macro
 
Random Solutions  
 
programming4us programming4us