View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Janis Janis is offline
external usenet poster
 
Posts: 360
Default delete a cell with a null value in column n

There are some values in cells in column "M" that are blank. If the cell is
null or blank I want to delete the entire row. I borrowed this script and I
don't understand what the "Is Nothing" stands for. Does it stand for "null"?
How can I fix it to delete the rows I don't need.

thanks,



-----------code----------------
Sub deleteRows()

Dim Rng As Range
Dim rngToSearch As Range
Dim rngToDelete As Range


With ActiveSheet
Set rngToSearch = .Range(.Range("M1"), .Cells(Rows.Count, "M").End(xlUp))
End With

For Each Rng In rngToSearch
If IsNull Then
If rngToDelete Is Nothing Then
Set rngToDelete = Rng
Else
Set rngToDelete = Union(rngToDelete, Rng)
End If
End If
Next Rng

If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete

End Sub