+ Reply to Thread
Results 1 to 5 of 5

Macro to delete entire rows where O2:O does not equal a date

  1. #1
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Macro to delete entire rows where O2:O does not equal a date

    Hi
    Can someone suggest to me a good efficient macro that would delete rows where O2:O does not equal a date. So if I have this information in the column O as below:

    Please Login or Register  to view this content.
    Then after the macro run it would only leave me header row and the rows with dates like this.
    Please Login or Register  to view this content.
    Any ideas?


    Cheers
    Rain
    Last edited by rain4u; 04-20-2011 at 10:38 PM. Reason: Solved

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Macro to delete entire rows where O2:O does not equal a date

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: Macro to delete entire rows where O2:O does not equal a date

    Hi
    Thank you for answering.
    Offered code does not remove all unwanted rows. Please see attached xls


    Any ideas
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: Macro to delete entire rows where O2:O does not equal a date

    Offered code does not remove all unwanted rows.
    If you are going to delete by looping thru rows you MUST loop from the bottom and move up OR... you can delete all rows of certain type at one time like the following code does.
    This code deletes all rows that have a constant that is not a number or date.

    FAST ONE STEP METHOD
    Please Login or Register  to view this content.
    .
    .
    .
    .
    LOOP METHOD (slower but works)


    Please Login or Register  to view this content.
    Last edited by nimrod; 04-20-2011 at 08:16 PM.

  5. #5
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: Macro to delete entire rows where O2:O does not equal a date

    The fast version will do. Thank you. Column O will always have either a date or text in it. It will never contain just numbers like "1" or "2". And even if it will have a number as the first character lets say number 2, it would always have some text to go along with it, so it would be classed as a text. Lets say "2 will be shipped". So the fast code fits the bill!
    Thank you!


    Cheers
    Rain

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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