Hello All,
I'm asking a similar question I asked earlier today but simplifying it.
I have an existing code that filters out and deletes the rows I don't need.
What I want to do is keep any dates Greater than or equal to Month(Date) (today's date) So today is 10/1/2015 If a cell in AI was lets say 02/15/2014, it would be deleted.
This is the part of the code I need to edit for dates. The code above was for clarification
I ALSO want to include in the criteria, "if Date in AI is 15 days less than todays date but only if Today falls within first 15 days of the month)" Then
Here's an Example of what I'm talking about.
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Today's Date[/TD]
[TD]Column AI[/TD]
[TD]Delete Row?[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]9/1/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]9/28/2015[/TD]
[TD]No[/TD]
[TD]Not current month, w/in 15 days[/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]10/2/2015[/TD]
[TD]No[/TD]
[TD]Current month[/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]11/7/2015[/TD]
[TD]No[/TD]
[TD]Past Current month[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Today's Date[/TD]
[TD]Column AI[/TD]
[TD]Delete Row?[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]9/1/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]9/28/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]10/2/2015[/TD]
[TD]No[/TD]
[TD]Current month[/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]11/7/2015[/TD]
[TD]No[/TD]
[TD]Past Current month[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Today's Date[/TD]
[TD]Column AI[/TD]
[TD]Delete Row?[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]9/1/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]9/28/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]10/2/2015[/TD]
[TD]No[/TD]
[TD]Current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]11/7/2015[/TD]
[TD]No[/TD]
[TD]Past Current month[/TD]
[/TR]
</tbody>[/TABLE]
Long story short. Need to establish Today's date, if column AI has date in same month or greater, don't delete that row.
If Today's Date falls within first 15 days of current month, subtract 15 days from today's date and delete rows that are less than that as in example (Today = 10/10/2015 and AI = 9/18/2015)
Thanks in advance for your help
Edit: The Formula needs to ignore BLANK cells. Blanks are good and I want to keep them on the report.
I'm asking a similar question I asked earlier today but simplifying it.
I have an existing code that filters out and deletes the rows I don't need.
Code:
Dim iRow As Long
Dim LastRow As Long
Dim sh1 As Worksheet
Set sh1 = Sheets("TEST2")
LastRow = sh1.Range("AI1").CurrentRegion.Rows.Count
For iRow = LastRow To 2 Step -1
If Cells(iRow, "AI1") < [U][Current Month][/U] Or [U][15 days less than Today if Today is within 15 days of current month][/U] AND [U][Skip Blank Cells][/U] Then
Rows(iRow).Delete
End If
Next iRow
What I want to do is keep any dates Greater than or equal to Month(Date) (today's date) So today is 10/1/2015 If a cell in AI was lets say 02/15/2014, it would be deleted.
This is the part of the code I need to edit for dates. The code above was for clarification
Code:
[COLOR=#333333] If Cells(iRow, "AI1") < [/COLOR][U][Current Month][/U][COLOR=#333333] Or [/COLOR][U][15 days less than Today if Today is within 15 days of current month][/U][COLOR=#333333] AND [/COLOR][U][Skip Blank Cells][/U][COLOR=#333333] Then[/COLOR]
I ALSO want to include in the criteria, "if Date in AI is 15 days less than todays date but only if Today falls within first 15 days of the month)" Then
Here's an Example of what I'm talking about.
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Today's Date[/TD]
[TD]Column AI[/TD]
[TD]Delete Row?[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]9/1/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]9/28/2015[/TD]
[TD]No[/TD]
[TD]Not current month, w/in 15 days[/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]10/2/2015[/TD]
[TD]No[/TD]
[TD]Current month[/TD]
[/TR]
[TR]
[TD]10/1/2015[/TD]
[TD]11/7/2015[/TD]
[TD]No[/TD]
[TD]Past Current month[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Today's Date[/TD]
[TD]Column AI[/TD]
[TD]Delete Row?[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]9/1/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]9/28/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]10/2/2015[/TD]
[TD]No[/TD]
[TD]Current month[/TD]
[/TR]
[TR]
[TD]10/15/2015[/TD]
[TD]11/7/2015[/TD]
[TD]No[/TD]
[TD]Past Current month[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Today's Date[/TD]
[TD]Column AI[/TD]
[TD]Delete Row?[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]9/1/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]9/28/2015[/TD]
[TD]Yes[/TD]
[TD]Not current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]10/2/2015[/TD]
[TD]No[/TD]
[TD]Current month, past 15 days[/TD]
[/TR]
[TR]
[TD]10/20/2015[/TD]
[TD]11/7/2015[/TD]
[TD]No[/TD]
[TD]Past Current month[/TD]
[/TR]
</tbody>[/TABLE]
Long story short. Need to establish Today's date, if column AI has date in same month or greater, don't delete that row.
If Today's Date falls within first 15 days of current month, subtract 15 days from today's date and delete rows that are less than that as in example (Today = 10/10/2015 and AI = 9/18/2015)
Thanks in advance for your help
Edit: The Formula needs to ignore BLANK cells. Blanks are good and I want to keep them on the report.
Last edited: