ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Entire Row (https://www.excelbanter.com/excel-programming/329687-delete-entire-row.html)

Tony P.[_3_]

Delete Entire Row
 
Okay, I'm stumped. Here is what I want to do:

Colum F contains inventory quantities. I want to delete all rows where
inventory numbers in column F are 0. I know there is a way to do this but I
can't seem to figure it out. Any help is much appreciated as always!

Tony P.

Brotha Lee

Delete Entire Row
 
Use autofilter and then custom. Here you can filter all values 0 and then
delete the rows or

use the following code to do it

Columns("A:A").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="0", Operator:=xlAnd

Set rng = Range("a1").CurrentRegion
rng.Offset(1, 0).Resize(rng.Rows.Count - 1, _
rng.Columns.Count).Select
Selection.EntireRow.Delete

"Tony P." schreef:

Okay, I'm stumped. Here is what I want to do:

Colum F contains inventory quantities. I want to delete all rows where
inventory numbers in column F are 0. I know there is a way to do this but I
can't seem to figure it out. Any help is much appreciated as always!

Tony P.


Ron de Bruin

Delete Entire Row
 
Hi Tony

Here is a example for row 1 -100

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 100
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "F").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "F").Value 0 Then .Rows(Lrow).Delete
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


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



"Tony P." wrote in message ...
Okay, I'm stumped. Here is what I want to do:

Colum F contains inventory quantities. I want to delete all rows where
inventory numbers in column F are 0. I know there is a way to do this but I
can't seem to figure it out. Any help is much appreciated as always!

Tony P.




Tony P.[_3_]

Delete Entire Row
 
Never thought of using the filter. Beautiful! Thanks!

"Brotha lee" wrote:

Use autofilter and then custom. Here you can filter all values 0 and then
delete the rows or

use the following code to do it

Columns("A:A").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="0", Operator:=xlAnd

Set rng = Range("a1").CurrentRegion
rng.Offset(1, 0).Resize(rng.Rows.Count - 1, _
rng.Columns.Count).Select
Selection.EntireRow.Delete

"Tony P." schreef:

Okay, I'm stumped. Here is what I want to do:

Colum F contains inventory quantities. I want to delete all rows where
inventory numbers in column F are 0. I know there is a way to do this but I
can't seem to figure it out. Any help is much appreciated as always!

Tony P.



All times are GMT +1. The time now is 07:44 PM.

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