S
Shaz
Hello
The macro below examines a column that has the heading "ID" in sheet
one and if it does not find a match within Column A in sheet "ID" it
deletes the row. I thought the "ID" column on Sheet 1 would always be
in Column C but alas this is not always the case.
It needs amending but being VBA challenged I'm struggling. Can you
help?
Thanks in advance.
Shaz
Public Sub Sorted()
Dim LRowData As Long, LRowTable As Long
LRowData = Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
LRowTable = Sheets("ID").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Sheet1").Activate
Dim ir As Long, it As Long, NotFound As Boolean
For ir = LRowData To 1 Step -1
NotFound = True
For it = 1 To LRowTable
If Cells(ir, 3).Value = Sheets("ID").Cells(it, 1).Value Then
NotFound = False
Next it
If NotFound Then Rows(ir).EntireRow.Delete Shift:=xlUp
Next ir
End Sub
The macro below examines a column that has the heading "ID" in sheet
one and if it does not find a match within Column A in sheet "ID" it
deletes the row. I thought the "ID" column on Sheet 1 would always be
in Column C but alas this is not always the case.
It needs amending but being VBA challenged I'm struggling. Can you
help?
Thanks in advance.
Shaz
Public Sub Sorted()
Dim LRowData As Long, LRowTable As Long
LRowData = Sheets("Sheet1").Cells(Rows.Count, "C").End(xlUp).Row
LRowTable = Sheets("ID").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Sheet1").Activate
Dim ir As Long, it As Long, NotFound As Boolean
For ir = LRowData To 1 Step -1
NotFound = True
For it = 1 To LRowTable
If Cells(ir, 3).Value = Sheets("ID").Cells(it, 1).Value Then
NotFound = False
Next it
If NotFound Then Rows(ir).EntireRow.Delete Shift:=xlUp
Next ir
End Sub