+ Reply to Thread
Results 1 to 7 of 7

Macro help

  1. #1
    Forum Contributor
    Join Date
    06-05-2006
    Posts
    166

    Macro help

    Can anyone help me write a macro that deletes the entire row if the cell in the corresponding row in column AL = "0" ?

    Thanks

    Phil

  2. #2
    Don Guillett
    Guest

    Re: Macro help

    try

    for i =cells(rows.count,"al").end(xlup).row to 2 step -1
    if cells(i,"al")=0 then rows(i).delete
    next i

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "phil2006" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Can anyone help me write a macro that deletes the entire row if the cell
    > in the corresponding row in column AL = "0" ?
    >
    > Thanks
    >
    > Phil
    >
    >
    > --
    > phil2006
    > ------------------------------------------------------------------------
    > phil2006's Profile:
    > http://www.excelforum.com/member.php...o&userid=35092
    > View this thread: http://www.excelforum.com/showthread...hreadid=566272
    >




  3. #3
    Forum Contributor
    Join Date
    06-05-2006
    Posts
    166
    Thanks! This isn't working entirely tho. I want the row deleted if the cell has the value "0". Alternatively if I could Fill the whole row with a colour it would be equally as effective and possibly more useful.

    Thanks



    Phil

  4. #4
    Gord Dibben
    Guest

    Re: Macro help

    Sub DeleteRows_With_Zero()
    findstring = "0"
    Set B = Columns(38).Find(What:=findstring, LookAt:=xlPart)
    While Not (B Is Nothing)
    B.EntireRow.Delete
    Set B = Columns(38).Find(What:=findstring, LookAt:=xlPart)
    Wend
    End Sub


    Gord Dibben MS Excel MVP

    On Sat, 29 Jul 2006 09:16:35 -0400, phil2006
    <[email protected]> wrote:

    >
    >Can anyone help me write a macro that deletes the entire row if the cell
    >in the corresponding row in column AL = "0" ?
    >
    >Thanks
    >
    >Phil



  5. #5
    Dave Peterson
    Guest

    Re: Macro help

    I think xlPart should be replaced with xlWhole.

    707 should be kept
    0 should be deleted.



    Gord Dibben wrote:
    >
    > Sub DeleteRows_With_Zero()
    > findstring = "0"
    > Set B = Columns(38).Find(What:=findstring, LookAt:=xlPart)
    > While Not (B Is Nothing)
    > B.EntireRow.Delete
    > Set B = Columns(38).Find(What:=findstring, LookAt:=xlPart)
    > Wend
    > End Sub
    >
    > Gord Dibben MS Excel MVP
    >
    > On Sat, 29 Jul 2006 09:16:35 -0400, phil2006
    > <[email protected]> wrote:
    >
    > >
    > >Can anyone help me write a macro that deletes the entire row if the cell
    > >in the corresponding row in column AL = "0" ?
    > >
    > >Thanks
    > >
    > >Phil


    --

    Dave Peterson

  6. #6
    Gord Dibben
    Guest

    Re: Macro help

    Thanks Dave.

    This is the second time I have posted this code without making the correction.

    Will make the change and re-archive.


    Gord

    On Sat, 29 Jul 2006 11:07:10 -0500, Dave Peterson <[email protected]>
    wrote:

    >I think xlPart should be replaced with xlWhole.
    >
    >707 should be kept
    >0 should be deleted.
    >
    >
    >
    >Gord Dibben wrote:
    >>
    >> Sub DeleteRows_With_Zero()
    >> findstring = "0"
    >> Set B = Columns(38).Find(What:=findstring, LookAt:=xlPart)
    >> While Not (B Is Nothing)
    >> B.EntireRow.Delete
    >> Set B = Columns(38).Find(What:=findstring, LookAt:=xlPart)
    >> Wend
    >> End Sub
    >>
    >> Gord Dibben MS Excel MVP
    >>
    >> On Sat, 29 Jul 2006 09:16:35 -0400, phil2006
    >> <[email protected]> wrote:
    >>
    >> >
    >> >Can anyone help me write a macro that deletes the entire row if the cell
    >> >in the corresponding row in column AL = "0" ?
    >> >
    >> >Thanks
    >> >
    >> >Phil


    Gord Dibben MS Excel MVP

  7. #7
    Forum Contributor
    Join Date
    06-05-2006
    Posts
    166
    Thanks very much for your help!

+ 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