Macro to delete entire row based on empty cell

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

Guest

Hi All
I've been trying to write a macro that deletes an entire row if a cell in a selection is empty
I've tried two different types, but both leaves cells if there is multiple blank cells between cells containing data. I.e. 5 blank cells between cells containing data
Could someone have a look at either one and suggest any appropriate modifications

Cheers and thanks
Al

Dim ThisCell As Rang
For Each ThisCell In Selectio
If ThisCell = Empty Then ThisCell.EntireRow.Delet
Next ThisCel



Dim ThisCell As Rang
For Each ThisCell In Selectio
If ThisCell.Value = Empty The
ThisCell.EntireRow.Delete shift:=xlU
End I
Next ThisCel
 
Assuming all rows should be deleted if the corresponding cell in Column F is
blank, then.....
Columns("F:F").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

If you are looking at a particular range in Column F then....
Range("F100:F1000").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

--
XL2002
Regards

William

(e-mail address removed)

| Hi All,
| I've been trying to write a macro that deletes an entire row if a cell in
a selection is empty.
| I've tried two different types, but both leaves cells if there is multiple
blank cells between cells containing data. I.e. 5 blank cells between cells
containing data.
| Could someone have a look at either one and suggest any appropriate
modifications?
|
| Cheers and thanks.
| Al.
|
|
| Dim ThisCell As Range
| For Each ThisCell In Selection
| If ThisCell = Empty Then ThisCell.EntireRow.Delete
| Next ThisCell
|
| &
|
| Dim ThisCell As Range
| For Each ThisCell In Selection
| If ThisCell.Value = Empty Then
| ThisCell.EntireRow.Delete shift:=xlUp
| End If
| Next ThisCell
|
 

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