[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
' Define local variable
Dim shtMain As Worksheet
Dim shtData As Worksheet
Dim rngMain As Range
Dim rngData As Range
Dim lngRow As Long
' Turn off screen updating
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
' Work with Sheet1 and Sheet2
Set shtMain = ThisWorkbook.Worksheets(1)
Set shtData = ThisWorkbook.Worksheets(2)
' Key values found in first column, starting at first row
Set rngMain = shtMain.Range(shtMain.Cells(1, 1), shtMain.Cells(shtMain.Cells(shtMain.Rows.Count, 1).End(xlUp).Row, 1))
Set rngData = shtData.Range(shtData.Cells(1, 1), shtData.Cells(shtData.Cells(shtData.Rows.Count, 1).End(xlUp).Row, 1))
' Check value from first sheet against second, delete row if match found
For lngRow = rngMain.Rows.Count To 1 Step -1
If Not IsError(Application.VLookup(rngMain.Cells(lngRow, 1), rngData, 1, False)) Then
' Turn on screen updating
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Open in new window
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.