VBA Delete Excel Rows Based on Certain Date

Let say I have a bunch of formatted data in my Excel sheet, and in Column A I have a dates. Then I wanna filter all the data base on certain date, for example 1 Jan 2009, and delete all others data before that date.

The algorithm is like this: I’ll create a loop from the first row until the last row with data and check if the date is before Jan 1st, 2009 or not, if it is, simply delete that row.

Sub DeleteFilteredRows()
    Dim i As Long

    For i = 1 To Cells.SpecialCells(xlCellTypeLastCell).Row
        Debug.Print Cells(i, "A").Value
        If CDate(Cells(i, "A")) < CDate("1/jan/2009") Then
            Cells(i, "A").EntireRow.Delete
        End If
    Next i

End Sub

Of course I’ll make an adjustment to the code above to meet my current condition.

FIN.

This entry was posted in Cells and Range, Workbook and Worksheet and tagged , , , , , , , . Bookmark the permalink.

1,066 Responses to VBA Delete Excel Rows Based on Certain Date

  1. garbo7441 says:

    This macro will delete all rows that contain a date before August 1, 2008.

    Sub DeleteRows()
    
    Dim i As Long
    For i = Cells(Rows.Count, K). _
    End(xlUp).Row To 1 Step -1
    If Cells(i, K) < 39661 Then
    Cells(i, K).EntireRow.Delete
    End If
    Next i
    
    End Sub
    
  2. Pingback: Q1 2009 Wrap up - Code For Excel And Outlook Blog

  3. Pingback: Q1 2009 Wrap up

  4. Xavier says:

    It returns a run-time error 1004, plz help

  5. Pingback: My Homepage

  6. Pingback: elektrische Zahnbürste

  7. Pingback: reverse mortgage costs

  8. Pingback: icdc college online

  9. Pingback: free credit card report

  10. Pingback: boxfresh men line

  11. Pingback: sofas

  12. Pingback: audio visual

  13. Pingback: learn to drive

  14. Pingback: fancy dress

  15. Pingback: golf swing tips

  16. Pingback: hotel parking games

  17. Pingback: www.openofficefreedownload.org

  18. Pingback: keratosis pilaris remedies

  19. Pingback: Verführung

  20. Pingback: watch the super bowl online 2012

  21. Pingback: Savoir mise sous tutelle

  22. Pingback: Alarmanlagen BKH Sicherheitstechnik ist Spezialist für mechatronische Schließsysteme, Schließanlagen, Zutrittskontrolle, Einbruchmelde- u. Videoüberwachungsanlagen, Rettungswegtechnik, Rauchwarnsysteme, Alarmierungssysteme sowie Briefkastenanlagen und Tre

  23. Pingback: apps for kids

  24. Pingback: priority cash advance

  25. Pingback: Landscape Gardeners North London

  26. Pingback: designvox in grand rapids

  27. Pingback: Ares Free Download

  28. Pingback: Audacity Download

  29. Pingback: Open Office

  30. Pingback: bed bath and beyond coupon code

  31. Pingback: best buy coupon code

  32. Pingback: Alternative Energy Projects

  33. Pingback: laser eye surgery risks

  34. Pingback: xenadrine reviews

  35. Pingback: car games

  36. Pingback: i gun app

  37. Pingback: viagra bez recepty

  38. Pingback: tania viagra

  39. Pingback: kamagra

  40. Pingback: cialis

  41. Pingback: water heater maintenance

  42. Pingback: Lastminute Urlaub buchen

  43. Pingback: slushie maker

  44. Pingback: The Smokenator is a great solution for smoking meat on a charcoal grill without the expense of a smoker.

  45. Pingback: brandon tile cleaning

  46. Pingback: cocktailkleider

  47. Pingback: manipulative psychology 101

  48. Pingback: dilandau

  49. Pingback: no deposit bingo sites

  50. Pingback: ariel rebel

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>