+ Reply to Thread
Results 1 to 3 of 3

Delete an entire Row if 2 Columns = Zero Q

  1. #1
    John
    Guest

    Delete an entire Row if 2 Columns = Zero Q

    The code below deletes the entire row starting upwards from row 500 if the
    value in H=0, but if E=VAT then ignore regardless if H in that particular
    row = 0.

    For i = Range("E500").End(xlUp).Row To 2 Step -1
    If Left(Range("E" & i).Value, 3) <> "VAT" Then
    If Range("H" & i).Value = 0 Then
    Range("H" & i).EntireRow.Delete
    End If
    End If
    Next i


    I wish to modify this slightly that even if E=VAT the row will still be
    deleted if L=0. So in effect if H & L are "both" Zero, delete the entire
    row. How would I do that

    Thanks



  2. #2
    Tom Ogilvy
    Guest

    Re: Delete an entire Row if 2 Columns = Zero Q

    For i = Range("E500").End(xlUp).Row To 2 Step -1
    If Left(Range("E" & i).Value, 3) <> "VAT" or _
    Range("L" & i).Value = 0 Then
    If Range("H" & i).Value = 0
    Range("H" & i).EntireRow.Delete
    End If
    End If
    Next i

    --
    Regards,
    Tom Ogilvy


    "John" <[email protected]> wrote in message
    news:[email protected]...
    > The code below deletes the entire row starting upwards from row 500 if the
    > value in H=0, but if E=VAT then ignore regardless if H in that particular
    > row = 0.
    >
    > For i = Range("E500").End(xlUp).Row To 2 Step -1
    > If Left(Range("E" & i).Value, 3) <> "VAT" Then
    > If Range("H" & i).Value = 0 Then
    > Range("H" & i).EntireRow.Delete
    > End If
    > End If
    > Next i
    >
    >
    > I wish to modify this slightly that even if E=VAT the row will still be
    > deleted if L=0. So in effect if H & L are "both" Zero, delete the entire
    > row. How would I do that
    >
    > Thanks
    >
    >




  3. #3
    John
    Guest

    Re: Delete an entire Row if 2 Columns = Zero Q

    Thanks Tom

    Just a "Then" missing from - If Range("H" & i).Value = 0


    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > For i = Range("E500").End(xlUp).Row To 2 Step -1
    > If Left(Range("E" & i).Value, 3) <> "VAT" or _
    > Range("L" & i).Value = 0 Then
    > If Range("H" & i).Value = 0
    > Range("H" & i).EntireRow.Delete
    > End If
    > End If
    > Next i
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "John" <[email protected]> wrote in message
    > news:[email protected]...
    >> The code below deletes the entire row starting upwards from row 500 if
    >> the
    >> value in H=0, but if E=VAT then ignore regardless if H in that particular
    >> row = 0.
    >>
    >> For i = Range("E500").End(xlUp).Row To 2 Step -1
    >> If Left(Range("E" & i).Value, 3) <> "VAT" Then
    >> If Range("H" & i).Value = 0 Then
    >> Range("H" & i).EntireRow.Delete
    >> End If
    >> End If
    >> Next i
    >>
    >>
    >> I wish to modify this slightly that even if E=VAT the row will still be
    >> deleted if L=0. So in effect if H & L are "both" Zero, delete the entire
    >> row. How would I do that
    >>
    >> Thanks
    >>
    >>

    >
    >




+ 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