View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default only deletes first row with a blank cell in column "M" con't

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).Entire Row.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
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

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...
--
HTH...

Jim Thomlinson


"Janis" wrote:

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?