Wookbook_Open Message Giving Count of Records not Closed for More than Specified Number of Days

Gos-C

Active Member
Joined
Apr 11, 2005
Messages
258
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I am trying to add a code so that when a user opens his/her workbook he/she gets a message with the number of records opened 30 days or more with a close date. The open date is in column C and the close date is in column AA.

I tried the following (which is not working):

Code:
Private Sub Workbook_Open()
'Sub Test_PastDueClose()
Dim cPast As Long, dRng As Range, cRng As Range
Set dRng = Sheets("LOG").Range("C4:C" & Cells(Rows.Count, 3).End(xlUp).Row)
Set cRng = Sheets("LOG").Range("AA4:AA" & Cells(Rows.Count, 27).End(xlUp).Row)
cPast = 0
For Each cell In dRng
If DateDiff("d", Now(), dRng) >= 30 Then
If cRng = "" Then
cPast = cPast + 1
End If
Next cell

MsgBox "Your log has " & cPast & " records that have past their scheduled close date.  They are highlight RED."

End Sub

Any help, please?

Thank you,
Gos-C
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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