deleting values from a column

C

cdanu

I have a column of values and from time to time I have “0”. How can
erase these values of “0” but without leaving blank cells in the colum
and thus get a column with only the positive values in also in the sam
order? I would like to know if there is a macro for this!?

Dan
[email protected]
 
R

Ron de Bruin

Hi

Try this one for column A

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1
With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value = "0" Then .Rows(Lrow).Delete

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub

More delete examples you find here
http://www.rondebruin.nl/delete.htm
 
Top