+ Reply to Thread
Results 1 to 5 of 5

Code to delete rows based on status code in Column I

  1. #1
    Registered User
    Join Date
    07-10-2008
    Location
    Norwich, England
    MS-Off Ver
    Office XP
    Posts
    15

    Code to delete rows based on status code in Column I

    I'm trying to write a VBA script which will delete all rows in my Excel spreadsheet where Column I (which contains a status code) does not contain the word "Completed".

    At the moment, I'm doing this the other way round: my script is able to search for entries in Column I which contain the status codes "Pending", "Awaiting Authorisation", "In Progress" etc and delete them. The idea is that when all those rows are deleted, I'll only be left with rows which have a status of "Completed". This works fine at the moment. However, the concern is that if a brand new status code is added to the data file, my script would be unable to pick it up and delete it.

    This is a small sample of the code I'm currently using (which deletes all the rows with statuses other than Completed):

    Please Login or Register  to view this content.
    How can I re-write this so that it will delete all the rows where the status does not contain "Completed", regardless of whether new status codes are added in the future?
    Last edited by LemonTwist; 07-24-2009 at 11:29 AM. Reason: solved

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Code to delete rows based on status code in Column I

    Hi,
    mudraker has a solution for this that can be found here

  3. #3
    Registered User
    Join Date
    07-10-2008
    Location
    Norwich, England
    MS-Off Ver
    Office XP
    Posts
    15

    Re: Code to delete rows based on status code in Column I

    That worked well, thank you for your help.

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Code to delete rows based on status code in Column I

    Glad to help

  5. #5
    Registered User
    Join Date
    07-26-2009
    Location
    Sheffield. England
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Code to delete rows based on status code in Column I

    Quote Originally Posted by LemonTwist View Post
    I'm trying to write a VBA script which will delete all rows in my Excel spreadsheet where Column I (which contains a status code) does not contain the word "Completed".

    At the moment, I'm doing this the other way round: my script is able to search for entries in Column I which contain the status codes "Pending", "Awaiting Authorisation", "In Progress" etc and delete them. The idea is that when all those rows are deleted, I'll only be left with rows which have a status of "Completed". This works fine at the moment. However, the concern is that if a brand new status code is added to the data file, my script would be unable to pick it up and delete it.

    This is a small sample of the code I'm currently using (which deletes all the rows with statuses other than Completed):

    Please Login or Register  to view this content.
    How can I re-write this so that it will delete all the rows where the status does not contain "Completed", regardless of whether new status codes are added in the future?
    Hi LemonTwist,

    I'm actually trying to do something similar to what you've already got except that the cells won't be an exact match but till contain certain search strings...

    http://www.excelforum.com/excel-prog...ht=delete+rows

    ...I was wondering if you could share the full code you've got with me please.

+ 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