Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete rows using VBA 1

Status
Not open for further replies.

cabUK

Mechanical
Jun 14, 2004
20
0
0
GB
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
 
Replies continue below

Recommended for you

Try this:


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
 
fyi . . .

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
 
Status
Not open for further replies.
Back
Top