only deletes first row with a blank cell in column "M" con't

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

Guest

It actually deletes the first two rows with "M" cells blank. This is a guess
but it seemed to stop deleting/checking rows on a cell where the one above it
was blank also?
 
Do you have a formula that is returning Blank??? If so then that code won't
work and you will need a loop or something similar...
 
Are the cells truely empty or do they have blank spaces in them. Give this a
try...

Select Column M -> F5 -> Special Cells -> Blanks

If and or what gets highlighted?
 
How about this. It should delete all of the blank whether they are the result
of a formula or if the cell contains blank spaces... It is similat to waht
you first posted...

Sub DeleteBlanks()
Dim rngToSearch As Range
Dim rng As Range
Dim rngToDelete As Range

With ActiveSheet
On Error Resume Next
Columns("M").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0

Set rngToSearch = .Range(.Range("M1"), .Cells(Rows.Count, "M").End(xlUp))
For Each rng In rngToSearch
If Trim(rng.Value) = "" Then
If rngToDelete Is Nothing Then
Set rngToDelete = rng
Else
Set rngToDelete = Union(rng, rngToDelete)
End If
Next rng
If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete
End With
End Sub
 

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