View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych[_2_] Tim Zych[_2_] is offline
external usenet poster
 
Posts: 41
Default Delete cells in row A with just zeroes

Here's one way:
Save a backup copy and test first. Adjust the parameters as needed.

Sub FindNDelete()
Dim rng As Range, cell As Range
Dim strAddress1 As String, rngUnion As Range
Set rng = Range("A:A") 'adjust to suit
Set cell = rng.Find(0, _
LookIn:=xlValues, Lookat:=xlWhole)
If Not cell Is Nothing Then
strAddress1 = cell.Address
Do
If rngUnion Is Nothing Then
Set rngUnion = cell
Else
Set rngUnion = Union(cell, rngUnion)
End If
Set cell = rng.FindNext(cell)
Loop While Not cell Is Nothing And _
cell.Address < strAddress1
End If
If Not rngUnion Is Nothing Then
rngUnion.EntireRow.Delete
End If
End Sub

For more info see www.rubbershoe.com/deleterows.htm.


"Steven R. Berke" wrote in message
om...
I have a column of 4 digit numbers located in Row A that covers about
60 rows. At the bottom of the 4 digit numbers in row A are about 30
rows of zeroes. To the right of the zeroes are blank cells (column
B). To the right the cells of the four digit numbers above the zeroes
is information. Have you any suggestions as to how I can delete the
rows with just zeroes in column A without deleting any of the others
numbers in the rows above zeroes which may contain information.