Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to delete rows based on date
I have a spreadsheet with completion dates in column C. I want my macro to
look at each date, check to see if it's older than 30 days, and then delete the rows that are older than 30 days. I have a macro that seems to work, but I can't get it to loop (and I tried many times to make that happen). I'm missing the loop piece, but also want to make sure I've put the "formula" part in properly. Here's my macro: Public Sub Delete1() Range("c3").Select If ActiveCell.Value <= "TODAY()-30" Then ActiveCell.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If End Sub Thanks, PMO |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to delete rows based on date
Maybe
Public Sub Delete1() lastrow = Cells(Cells.Rows.Count, "C").End(xlUp).Row For x = lastrow To 3 Step -1 If Cells(x, 3).Value <= Date - 30 Then Cells(x, 3).EntireRow.Delete End If Next End Sub Mike "PMBO" wrote: I have a spreadsheet with completion dates in column C. I want my macro to look at each date, check to see if it's older than 30 days, and then delete the rows that are older than 30 days. I have a macro that seems to work, but I can't get it to loop (and I tried many times to make that happen). I'm missing the loop piece, but also want to make sure I've put the "formula" part in properly. Here's my macro: Public Sub Delete1() Range("c3").Select If ActiveCell.Value <= "TODAY()-30" Then ActiveCell.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If End Sub Thanks, PMO |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to delete rows based on date
PERFECT! No wonder you're gold level. Thank You.
"PMBO" wrote: I have a spreadsheet with completion dates in column C. I want my macro to look at each date, check to see if it's older than 30 days, and then delete the rows that are older than 30 days. I have a macro that seems to work, but I can't get it to loop (and I tried many times to make that happen). I'm missing the loop piece, but also want to make sure I've put the "formula" part in properly. Here's my macro: Public Sub Delete1() Range("c3").Select If ActiveCell.Value <= "TODAY()-30" Then ActiveCell.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If End Sub Thanks, PMO |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to delete rows based on date
Your welcome, glad I could help
"PMBO" wrote: PERFECT! No wonder you're gold level. Thank You. "PMBO" wrote: I have a spreadsheet with completion dates in column C. I want my macro to look at each date, check to see if it's older than 30 days, and then delete the rows that are older than 30 days. I have a macro that seems to work, but I can't get it to loop (and I tried many times to make that happen). I'm missing the loop piece, but also want to make sure I've put the "formula" part in properly. Here's my macro: Public Sub Delete1() Range("c3").Select If ActiveCell.Value <= "TODAY()-30" Then ActiveCell.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If End Sub Thanks, PMO |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete Rows based on value | Excel Worksheet Functions | |||
Delete Rows Based on Words | Excel Discussion (Misc queries) | |||
Macro to delete rows based on a condition | Excel Worksheet Functions | |||
Delete rows based on criteria | Excel Discussion (Misc queries) | |||
Delete rows based on certain criteria | Excel Discussion (Misc queries) |