+ Reply to Thread
Results 1 to 4 of 4

Delete Entire Row

  1. #1
    Tony P.
    Guest

    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.

  2. #2
    Brotha lee
    Guest

    RE: 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.


  3. #3
    Ron de Bruin
    Guest

    Re: 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." <[email protected]> wrote in message news:[email protected]...
    > 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.




  4. #4
    Tony P.
    Guest

    RE: 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.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1