Using Now() Command in VBA

Satch7

New Member
Joined
Jul 30, 2007
Messages
9
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?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
ActiveCell.Value > Now would be dates after today.
I think you want this: ActiveCell.Value < Now
 
Upvote 0
I think I have confused the issue.

I want the risk log to show all risk that have a raised on date that is less than todays so I can see the old one, therefire deleting all the risks with a raised on date that is >now()

The one with a greater than today date should not be showing.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top