deleting the blank rows from the sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Thanx for replying me in time for my earlier question.

I have a data of 15000 rows. My problem is there are spaces of a row or two
between each records. I could have sort it to remove the blank rows in
between. But do not want to change the order of the records. pls suggest
the right way to remove blank rows from the records in short period of time.

thanx in advance.
Manu
 
Hi,

I have assumed that if the cell in column A is empty then this identifies a
blank row. If that is correct then right click the sheet tab, view code and
paste this in:-

Sub surface()
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

For x = LastRow To 1 Step -1
Cells(x, 1).Select
If Cells(x, 1).Value = "" Then
Selection.EntireRow.Delete
End If
Next
End Sub

Mike
 
Its working.

Thanx a lot.

rgds,
Manu

Mike H said:
Hi,

I have assumed that if the cell in column A is empty then this identifies a
blank row. If that is correct then right click the sheet tab, view code and
paste this in:-

Sub surface()
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

For x = LastRow To 1 Step -1
Cells(x, 1).Select
If Cells(x, 1).Value = "" Then
Selection.EntireRow.Delete
End If
Next
End Sub

Mike
 
Personally, I would use:

Sub surface()

Dim rng As Range

Set rng = Application.Intersect(Cells.Columns(1), ActiveSheet.UsedRange)

On Error Resume Next
rng.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0

End Sub
 
Select a column and F5>Special>Blanks>OK

Edit>Delete>Entire Row.


Gord Dibben MS Excel MVP
 

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

Back
Top