how to delete empty row in vba

L

Lillian

I have one excel spreed sheet, I need to delete all the
empty row, also some of cell in columnF if is the space,
then this record need to delete as well.
Anyone know how to write the vba macro?

thanks.

Lillian
 
R

Ron de Bruin

Hi

Please stay in your other thread

Run the TRIMALL macro I posted in that thread
And run this macro if you want to delete each row if the whole row is empty.


Sub DeleteEmptyRows()
'Dave Braden
Dim l As Long, rng As Range, rngDel As Range

On Error Resume Next
Set rng = ActiveSheet.UsedRange
With rng.Columns
Set rngDel = .Item(1).SpecialCells(xlCellTypeBlanks).EntireRow

For l = 2 To .Count
Set rngDel = Intersect(rngDel, _
.Item(l).SpecialCells(xlCellTypeBlanks).EntireRow)
If rngDel Is Nothing Then Exit Sub
Next
End With
Application.ScreenUpdating = False
rngDel.Delete
End Sub
 
L

Lillian

Hi,

I did not konw how to run that TRIMALL macro, as I said
in the previous mail, I need to you told me too, still
not working, but I use the below script, all the empty
row is gone, that what I like it, thanks.

Now I need to delete the record when each rows of
columnF is space (" "), how to do that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top