Delete row if value does not exist

F

Freddy

I am using the below code to look down a column of values and if the value =
0, then delete the entire row.

I now have a list of 466 places on one sheet and a summary sheet with 8-10
laces

Would anyone know how to change the code to now look down the summary sheet
and then delete all those rows of places on the 1st sheets that are not on
the summary sheet

Your help is greatly appreciated

Code:


Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = 5
Lastrow = 466
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "B")
If Not IsError(.Value) Then
If .Value = 0 Then .EntireRow.Delete
End If
End With
Next Lrow
End With
 
J

Joel

Check the column in code below to see if they are correct. Code is search
column A on activesheet and summary sheet.

Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = 5
Lastrow = 466
For Lrow = Lastrow To Firstrow Step -1
data = .Cells(Lrow, "A")
with sheets("summary")
set c = .columns("A:A").find(what:=data, lookin:=xlvalues)

if not c is nothing then
c.entirerow.delete
End If
End With
Next Lrow
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top