View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Delete Empty Rows

'Delete Empty Rows
Dim ContentCount As Integer
Dim u As Integer
ContentCount = Range(("PContent" &
i)).Rows.Count
For u = ContentCount to 1 step -1
If Range("PContent" & i).Cells(u, 1).Value
= "" Then
Range("PContent" & i).Rows(u).Delete
End If
Next u

--
Regards,
Tom Ogilvy

"nxqviet" wrote:

Hi all

My question is about Macro that delete empty row in a data range. here
is the code that I have.

'Delete Empty Rows
Dim ContentCount As Integer
Dim u As Integer
ContentCount = Range(("PContent" &
i)).Rows.Count
For u = 1 To ContentCount
If Range("PContent" & i).Cells(u, 1).Value
= "" Then
Range("PContent" & i).Rows(u).Delete
End If
Next u

This is a part of a much larger code. On this sheet, I have many ranges
with the name of PContent1, PContent2,.... and "i" will be the count of
the number of Range that I'll use. And "u" is the count of the number
of Rows in every "i" Range.

This Code will look through the ranges that I used and Delete all the
empty Rows. The code seem to work fine, except it Deletes only a few
number of empty row in every given range, then move on to the next
range.

Please help, Thanks a lot,


V_