+ Reply to Thread
Results 1 to 5 of 5

VBA Help: delete whole row if the cell does not contain string "*"

  1. #1
    Registered User
    Join Date
    01-07-2006
    Posts
    2

    VBA Help: delete whole row if the cell does not contain string "*"

    Hi all,

    I am only a beginner in VBA. I have come across the problem where I have a range of data in excel. In each rows, I want to check if the cell in that row does contain a string "*".

    If the row where the cell does not contain string "*" I want to delete the whole row.


    I am having problem in figure out how to relate each cell search if it contains a string"*".

    Can anyone give me some idea/help?

    Thanks

    ZenZen

  2. #2
    Paul W Smith
    Guest

    Re: VBA Help: delete whole row if the cell does not contain string "*"

    Pseudo-code:

    Loop down the column of the cells you are checking, something like...

    Do
    {Check Deletion criteria}
    move one row down
    Loop until end criteria

    If the deletion criteria matches, move to the next row and then delete the
    previous.

    Checkcell.offset(-1,0).entirerow.delete

    HTH



    "zenzen" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi all,
    >
    > I am only a beginner in VBA. I have come across the problem where I
    > have a range of data in excel. In each rows, I want to check if the
    > cell in that row does contain a string "*".
    >
    > If the row where the cell does not contain string "*" I want to delete
    > the whole row.
    >
    >
    > I am having problem in figure out how to relate each cell search if it
    > contains a string"*".
    >
    > Can anyone give me some idea/help?
    >
    > Thanks
    >
    > ZenZen
    >
    >
    > --
    > zenzen
    > ------------------------------------------------------------------------
    > zenzen's Profile:
    > http://www.excelforum.com/member.php...o&userid=30224
    > View this thread: http://www.excelforum.com/showthread...hreadid=499014
    >




  3. #3
    Gary Keramidas
    Guest

    Re: VBA Help: delete whole row if the cell does not contain string "*"

    when you need to delete a row, it's better to start at the last row and work
    your way up.

    --


    Gary


    "zenzen" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi all,
    >
    > I am only a beginner in VBA. I have come across the problem where I
    > have a range of data in excel. In each rows, I want to check if the
    > cell in that row does contain a string "*".
    >
    > If the row where the cell does not contain string "*" I want to delete
    > the whole row.
    >
    >
    > I am having problem in figure out how to relate each cell search if it
    > contains a string"*".
    >
    > Can anyone give me some idea/help?
    >
    > Thanks
    >
    > ZenZen
    >
    >
    > --
    > zenzen
    > ------------------------------------------------------------------------
    > zenzen's Profile:
    > http://www.excelforum.com/member.php...o&userid=30224
    > View this thread: http://www.excelforum.com/showthread...hreadid=499014
    >




  4. #4
    Ron de Bruin
    Guest

    Re: VBA Help: delete whole row if the cell does not contain string "*"

    I have a few examples here
    http://www.rondebruin.nl/delete.htm

    You can change the = for <> to do what you want

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


    "zenzen" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hi all,
    >
    > I am only a beginner in VBA. I have come across the problem where I
    > have a range of data in excel. In each rows, I want to check if the
    > cell in that row does contain a string "*".
    >
    > If the row where the cell does not contain string "*" I want to delete
    > the whole row.
    >
    >
    > I am having problem in figure out how to relate each cell search if it
    > contains a string"*".
    >
    > Can anyone give me some idea/help?
    >
    > Thanks
    >
    > ZenZen
    >
    >
    > --
    > zenzen
    > ------------------------------------------------------------------------
    > zenzen's Profile: http://www.excelforum.com/member.php...o&userid=30224
    > View this thread: http://www.excelforum.com/showthread...hreadid=499014
    >




  5. #5
    Registered User
    Join Date
    01-07-2006
    Posts
    2

    Thank you!

    Thank you everyone!

    I now have some idea and will try it out

+ 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