Delete rows using VBA
Delete rows using VBA
(OP)
I am trying to cycle through rows in a spreadsheet and delete any rows that contain a 1 in the F column.
I am trying to do this using VBA and am wondering if anyone can give a hand on this.
Thanks
Craig
I am trying to do this using VBA and am wondering if anyone can give a hand on this.
Thanks
Craig





RE: Delete rows using VBA
Sub deleteF()
Dim i As Long, LastRow As Long
Application.ScreenUpdating = False
'finds last used row in column F
LastRow = Range("F65536").End(xlUp).Row
'begin loop to check each row for column F value=1
For i = LastRow To 1 Step -1
If Cells(i, "F") = 1 Then Rows(i).Delete
Next i
Application.ScreenUpdating = True
End Sub
RE: Delete rows using VBA
RE: Delete rows using VBA
there is a technique to accomplish the same goal without writing vba. use the autofilter capabilities within data menu (data ->filter -> autofilter).
select f column header and choose "1" from the list. select applicable rows and delete.
-pmover