Looking for vba to alert me when a date is 4 days old

Ike Hunter

New Member
Joined
Dec 15, 2011
Messages
35
Hi,
Looking for vba to alert me when a date is 4 days old and there is not a date in an another cell of the same row.

VBA runs when I open the workbook.

Column AC can be blank or have a date. Ignore all when cell in Col AC is blank

Column AE can be blank or have a date. Ignore all when cell in Col AE has a date

If row in Col AC has a date and that date is now 4 days old and same row in Col AE is blank

Then go to that cell(s), format cell red

And a msgbox alerting which cell(s) in Col AE needs attention.

Could be several rows with this issue.

Thank you in advance. :)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
This will require a little adjusting to your worksheet, but it should get you close.
VBA Code:
Private Sub Workbook_Open()

Dim myNumRows As Integer
Dim myStart As Integer
Dim ws As Worksheet

    ' Adjust as needed
    Set ws = ActiveWorkbook.Sheets("Sheet1")
    
    ' Which column is most likely to be full?  Change 1 below to that column.  1 will look at column "A"
    myNumRows = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

    ' Change this to 1 if you do not have a header row
    myStart = 2
    
    For i = myStart To myNumRows
        If ws.Range("AC" & i).Value <> "" And ws.Range("AE" & i).Value = "" Then
            If ws.Range("AC" & i).Value <= Now - 4 Then
                ws.Range("AC" & i).Interior.Color = vbRed
                MsgBox "The date in AC" & i & " is older than 4 days.", vbOKOnly, "Warning!"
            End If
        End If
    Next i

End Sub
 
Upvote 0
Solution
Perfect. Thank you very much. This will save my ..... :)
Not sure why. Even though the editor shows "Sheet1(Orders - Inventory)" I had to replace in your code..."Sheet1" to "Orders - Inventory", due to Run-time error '9'. I got it working though. Thanks again. :)
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,617
Members
449,039
Latest member
Mbone Mathonsi

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