I am trying to get the macro to run the following:
Select all data in one sheet (All) and pass into another (Due) then I am asking for it to look at the date in cell F2 and delete the entire row should the date be greater than today date (now()). This should show all the risks and issues that have a raised on a date of less than today's date.
Attached is a copy of the code with the offending piece of code in red Sub due()
Sheets("All").Select
Range("A1:m50").Select
Selection.Copy
Sheets("Due").Select
Range("A1").Select
ActiveSheet.Paste
Range("f2").Select
ActiveCell.Offset(0, 0).Select
Application.ScreenUpdating = False
For i = 1 To 50
If ActiveCell.Value > Now Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Next i
Application.ScreenUpdating = False
End Sub
The macro runs fine and I can get it to delete all the data row by row however it continues to delete the rows where the date is after today's date, which is shouldn’t do.
Can anyone help?
Select all data in one sheet (All) and pass into another (Due) then I am asking for it to look at the date in cell F2 and delete the entire row should the date be greater than today date (now()). This should show all the risks and issues that have a raised on a date of less than today's date.
Attached is a copy of the code with the offending piece of code in red Sub due()
Sheets("All").Select
Range("A1:m50").Select
Selection.Copy
Sheets("Due").Select
Range("A1").Select
ActiveSheet.Paste
Range("f2").Select
ActiveCell.Offset(0, 0).Select
Application.ScreenUpdating = False
For i = 1 To 50
If ActiveCell.Value > Now Then
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Next i
Application.ScreenUpdating = False
End Sub
The macro runs fine and I can get it to delete all the data row by row however it continues to delete the rows where the date is after today's date, which is shouldn’t do.
Can anyone help?