Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Delete certain rows.

Status
Not open for further replies.

MuskyMan

Technical User
Jul 31, 2002
36
US
I've got to go through a rather large workbook and delete certain rows. I can come up with loop but can't come up with the code to delete the row once the loop has found it.

Thanks in advance for the reply.
 
What is your actual code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I don't have the code written out however, I can tell you that the loop will look at the second column of the row and delete the row if this cell is empty.

if cell(r,2)=empty then delete the row.

Thanks
 
I don't have the code written out
So, how can we help you to fix your code ?

A starting point:
For r = lngLastRow To lngFirstRow Step -1
If Trim(yourWorksheetObject.Cells(r, 2)) = "" Then
yourWorksheetObject.Cells(r, 2).EntireRow.Delete
End If
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I can tell you that the loop will look at the second column of the row and delete the row if this cell is empty."

Why use code?

Turn on your Autofilter and filter on BLANKS in the second column.

Select the ROWS of data.

Right-click - DELETE.

Turn on your macro recorder if you need this recurring. Post back with your recorded code to customize.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top