ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   deleting values from a column (https://www.excelbanter.com/excel-programming/299880-deleting-values-column.html)

cdanu

deleting values from a column
 
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


--
Message posted from
http://www.ExcelForum.com


Ron de Bruin

deleting values from a column
 
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



--
Regards Ron de Bruin
http://www.rondebruin.nl


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

Dan



---
Message posted from
http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com