PDA

View Full Version : Solved: Delete row based on first cells contents?



exwarrior
01-15-2008, 11:43 AM
I'm looking for some code that would search down column A and where each cell equals "N" delete the row. Thanks in advance because this forum always delivers!

Bob Phillips
01-15-2008, 12:20 PM
Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long

With Application

.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = LastRow To 1 Step -1

If .Cells(i, "A").Value = "N" Then .Rows(i).Delete

Next i

End With

With Application

.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With

End Sub

exwarrior
01-22-2008, 02:10 PM
That works wonderfully as always XLD. Thanks

How can i add another step to go to the next page named "Locations" and do the same things by deleting blank rows by going down column "B".

Carl A
01-22-2008, 05:06 PM
Add this to the sub right before you set the screen updating back to True note: this will delete all blanks in column B

Worksheets("Locations").Range("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete