Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete Row when date in activecell doesn't meet the requierments
I have a worksheet containing startdate in Column G and enddate in Column H
per user. I want VBA to test if a user doesn't meet the specifics (from an inputbox), and then delete the entire row. So basically if user's contracted has to be activated on or after 1-1-2008 and expired on or before 31-12-2009, all users that do not meet those specifics get deleted. The date (i.e. criteria) should be entered through an inputbox. Thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete Row when date in activecell doesn't meet the requierments
If I understand you correctly you want to delete the entire row if the date
in Col.G is greater than 1-1-2008 and Col.H is less than 12-31-2009, right? This procedure will find the last row in Col.G and scan Col. G and Col.H till row 2. Option Explicit Sub DeleteRows() Dim lngLastRow As Long Dim i As Long lngLastRow = Sheets("Sheet1").Cells(Rows.Count, "G").End(xlUp).Row For i = lngLastRow To 2 Step -1 If Format(Cells(i, "G"), "m/dd/yyyy") "1/1/2008" Or _ Format(Cells(i, "H"), "m/dd/yyyy") < "12/31/2009" Then Rows(i).EntireRow.Delete Shift:=xlUp End If Next i End Sub Hope this helps! If so, let me know and click "YES" below. -- Cheers, Ryan "Basta1980" wrote: I have a worksheet containing startdate in Column G and enddate in Column H per user. I want VBA to test if a user doesn't meet the specifics (from an inputbox), and then delete the entire row. So basically if user's contracted has to be activated on or after 1-1-2008 and expired on or before 31-12-2009, all users that do not meet those specifics get deleted. The date (i.e. criteria) should be entered through an inputbox. Thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete data in cells that don't meet criteria | New Users to Excel | |||
Delete rows that do not meet specific criteria | Excel Programming | |||
Delete rows that don't meet specific criterion | New Users to Excel | |||
Delete Rows where cells does not meet criteria | Excel Worksheet Functions | |||
how do i delete rows when cells meet certain criteria? | Excel Programming |