Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Loop That Deletes Blank Rows

Status
Not open for further replies.

popnlok

Computer
Apr 20, 2004
2
I have a worksheet that contains a table, the entries in the table vary, so I need the table to adjust to the amount of entries in the table, so there isn't blank rows that are formatted with borderlines.

I was thinking something like "If Range is "", then delete..." That sort of logic, or maybe even something better if anyone knows.

Thanks in advance for any help you can give.
Anthony
 
Replies continue below

Recommended for you

Just loop through the required range (working from the bottom up), check cells for blank and delete row as required:
[tt]
Private Sub CommandButton1_Click()
Dim intRow As Integer
For intRow = 20 To 1 Step -1
With Range("A" & intRow)
If .Value = "" Then
Rows(intRow).Delete Shift:=xlUp
End If
End With
Next intRow
End Sub
[/tt]

That should get you started

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor