Moonbeam111
Board Regular
- Joined
- Sep 24, 2018
- Messages
- 73
- Office Version
- 365
- 2010
I have a workbook with two sheets open. There is a column A in sheet 1 with data from rows A1:A427 and column A in sheet 2 with data from A1:A355. I would like for every cell in column A sheet 2 from range A1:A355 be checked individually against every cell in sheet 1 column A1:A427. (They are alphabetized but I have extra data in sheet 1's columns I don't need). If the code finds a cell in sheet 1 that isn't in sheet 2, I would like for that entire row to be deleted from it in sheet 1. Is something like that possible to do with a macro?
VBA Code:
Sub Sheet1_Button1_Click()
Dim cell As Range, f As Range
For Each cell In Worksheets("Sheet1").Range("A2")
If cell <> Worksheets("Sheet2").Range("A2:A355") Then
cell.EntireRow.Delete
End If
Next cell
End Sub
[CODE=vba]
That didn't work.