Results 1 to 4 of 4

Deleting a row where a cell contains a date in a column

Threaded View

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2007
    Posts
    4

    Deleting a row where a cell contains a date in a column

    Hello,

    I am a novice when it comes to macros and I can't seem to solve my issue. I have a macro already set to modify columns, etc and at the end I need it to search for a certain date in a certain column and delete the entire row if the criteria is met. In my worksheet, I need it to search column N (for the entire worksheet) for a date that has a year of 1900. If 1900 is found in column N, regardless of month or day, it should delete the entire row. Currently an example of how the data looks in column N is 1900/01/01, but some formats include a time stamp. I believe my issue is with the way the date is formatted. I have tried the following but it is not deleting anything.


    Sub test()
    With ActiveSheet
        .AutoFilterMode = False
        With Range("n1", Range("n" & Rows.Count).End(xlUp))
            .AutoFilter 1, "1900"
            On Error Resume Next
            .Offset(1).SpecialCells(12).EntireRow.Delete
        End With
        .AutoFilterMode = False
    End With
    End Sub
    I have attached a sheet that has how the dates appear so you can see the formatting of the dates.date format.xlsx

    Any help is greatly appreciated. Thanks.
    Attached Files Attached Files
    Last edited by Cutter; 09-05-2012 at 07:49 PM. Reason: Added code tags

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