Try some code like the following. Change the line
Set WS = Worksheets("Sheet1") '<<< Change to appropriate sheet
to the appropriate worksheet. Change the line
TopRow = 1 '<<< change to first row number with data
to the first row number that might have data to delete. This assumes
that when you say "column b = 0" you mean that it has an actual value
of 0, not a default value of 0 as a result of being empty. This code
will not delete rows in which column B is empty.
Sub AAAA()
Dim RowNdx As Long
Dim LastRow As Long
Dim WS As Worksheet
Dim TopRow As Long
Set WS = Worksheets("Sheet1") '<<< Change to appropriate sheet
TopRow = 1 '<<< change to first row number with data
With WS
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To TopRow Step -1
If Len(.Cells(RowNdx, "B").Text) 0 Then
If .Cells(RowNdx, "B").Value = 0 Then
.Cells(RowNdx, "A").Resize(, 7).Delete
End If
End If
Next RowNdx
End With
End Sub
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Thu, 1 Jan 2009 14:50:07 -0800, jatman
wrote:
i am using the following code to delete the complete row:
Range("B:B").Select
Selection.AutoFilter Field:=1, Criteria1:="0"
On Error GoTo line1
With Sheet1.Range("b:b")
Cells.SpecialCells(xlCellTypeVisible).EntireRow.De lete
End With
line1:
what i need is to delete only columns a:g (not the entire row) if the value
in column b = 0.
any help is appreciated.
jat