How to detect and delete empty rows in a list?

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

Guest

I am preparing Excel lists I get from external sources to be used as databases. Some of them contain empty rows. How do I detect and delete those rows programmatically

Would be very pleased if somebody could help me with this proble
Steff
 
Set YourSheet = Worksheets("YourSheetnmae")

Do Until IsEmpty( YourSheet.Cells(i + 1, aColumn).Value)
If isempty(YourSheet.Cells(i + 1, aColumn).Value) Then
YourSheet.Cells(i + 1, aColumn).Select
Selection.Delete Shift:=xlUp
End If
i = i + 1
Loop
 
Steff,

Why don't you just sort?

Nikos

Steff said:
I am preparing Excel lists I get from external sources to be used as
databases. Some of them contain empty rows. How do I detect and delete those
rows programmatically?
 
Thanks all of you
Pearson's solution works fine, but unfortunately some of the seemingly empty cells in a seemingly empty row have been formatted e.g as numbers and are then not detected as empty

Kalles suggestion does not work with m

Nikos suggestion to sort has the disadvantage that the original sorting order is change

My own solution, finally, was to filter out all the values of a specific column that are >0
 
Steff,

In order to kee the original sorting:

* Use an extra column to add a serial number from the first data row down
(1,2,3, etc)
* Sort on the data itself and delete the blank rows (they are all at the top
or bottom of the data)
* Re-sort on the serial numbers, and you get your original sorting back! Now
you can also delete the S/N column.

HTH,
Nikos

Steff said:
Thanks all of you:
Pearson's solution works fine, but unfortunately some of the seemingly
empty cells in a seemingly empty row have been formatted e.g as numbers and
are then not detected as empty.
Kalles suggestion does not work with me

Nikos suggestion to sort has the disadvantage that the original sorting order is changed

My own solution, finally, was to filter out all the values of a specific
column that are >0
 
Wouldn't your code just stop when it hit the first empty cell, thus
appearing to do nothing.
 

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