![]() |
Delete row if value does not exist
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 |
Delete row if value does not exist
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 "Freddy" wrote: 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 |
All times are GMT +1. The time now is 03:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com