Not quite sure how to go about this reminder system

erutherford

Active Member
Joined
Dec 19, 2016
Messages
449
Looking for ideas on how to go about this reminder system I am trying to create.

The form has a combobx that list all of the cars that are in the system.
Each car has a max of 6 reminders.
Each reminder has a chkbx (turning the reminder on/off), textbox for description, combox bx for number days before popup msgbox says "due".

The worksheet is setup for each car has a row.
Col A = Car Name
Col B = Expiration Date
Col C = Status (TRUE or FALSE)
Col D = Alert Date (number of days before Expiration Date)

I was going to have a popup for each date that has "expired", but then I might have a bunch of popup at one time. Is there a way to have expired dates as line items in a listbox or textbox. Sort of like a list all in one place?

looking for a strategy, concept OR better yet a sample of something close.

thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
What triggers the check for expired items?

Are you alerting on the Alert Date having passed, or the Expiration Date?

The simplest option to me looks to be create a string where each car you want to alert about is separated by a newline

VBA Code:
Dim cCar As Range, sh As Worksheet, strAlert As String, dtTest As Date

Set sh = ThisWorkbook.Worksheets("CarList")

Set cCar = sh.Cells(1, 1)

Do Until cCar.Value = ""
    dtTest = cCar.Offset(0, 1) 'Change to cCar.Offset(0,3) if you want the alert date used, rather than Expiration date
    
    If dtTest < Date And cCar.Offset(0, 2).Value Then
        strAlert = strAlert & cCar.Value & " expired on " & Format(dtTest, "yyyy-mm-dd") & vbCrLf 'vbCrLf puts a newline (Carriage Return, Line Feed) in
    End If

    Set cCar = cCar.Offset(1, 0)
Loop

If strAlert = "" Then strAlert = "No expired cars found"

MsgBox strAlert
 
Upvote 0
Wow thanks for the example!!!!

What triggers the check for expired items? - The due date + Alert days. TextBox1=the due date, then a checkbox to select the number of dates before the due date.
 
Upvote 0
OK - So Due date is a date, and Alert Dates is a number. An example row might be like this;

1579702706369.png


The due date is 20th Feb, the Alter Dates is 30.

This will include the Astra every time the routine is run from the 21st Jan (30 days before the due date) onwards;

VBA Code:
Dim cCar As Range, sh As Worksheet, strAlert As String, dtTest As Date

Set sh = ThisWorkbook.Worksheets("CarList")

Set cCar = sh.Cells(1, 1)

Do Until cCar.Value = ""
    dtTest = cCar.Offset(0, 1) 
    dtTest = dateadd("d",cCar.Offset(0,3)*-1,dtTest)

    If dtTest <= Date And cCar.Offset(0, 2).Value Then
        strAlert = strAlert & cCar.Value & " expired on " & Format(dtTest, "yyyy-mm-dd") & vbCrLf 'vbCrLf puts a newline (Carriage Return, Line Feed) in
    End If

    Set cCar = cCar.Offset(1, 0)
Loop

If strAlert = "" Then strAlert = "No expired cars found"

MsgBox strAlert

This will do it every day from the 21st March (30 days *after* the due date)


VBA Code:
Dim cCar As Range, sh As Worksheet, strAlert As String, dtTest As Date

Set sh = ThisWorkbook.Worksheets("CarList")

Set cCar = sh.Cells(1, 1)

Do Until cCar.Value = ""
    dtTest = cCar.Offset(0, 1) 
    dtTest = dateadd("d",cCar.Offset(0,3),dtTest)

    If dtTest <= Date And cCar.Offset(0, 2).Value Then
        strAlert = strAlert & cCar.Value & " expired on " & Format(dtTest, "yyyy-mm-dd") & vbCrLf 'vbCrLf puts a newline (Carriage Return, Line Feed) in
    End If

    Set cCar = cCar.Offset(1, 0)
Loop

If strAlert = "" Then strAlert = "No expired cars found"

MsgBox strAlert

The difference is in the "dateadd" function - in the first version I am multiplying the alert dates by -1 (to deduct them from the due date) and in the second I am not, so as to add them.
 
Upvote 0
What triggers the check for expired items? - The due date + Alert days. TextBox1=the due date, then a checkbox to select the number of dates before the due date.

I meant, what triggers the code to run, and check for expired cars?
 
Upvote 0
I haven't decided that yet. I was first thinking every time the workbook open, but I would think it should just be automatic based on the PC clock?
 
Upvote 0
Are you alerting on the Alert Date having passed, or the Expiration Date? - Alert Date Passing

The simplest option to me looks to be create a string where each car you want to alert about is separated by a newline - I agree, Simple is best.
 
Upvote 0
I haven't decided that yet. I was first thinking every time the workbook open, but I would think it should just be automatic based on the PC clock?

It will not run unless the workbook is open (well - there's a route you can go down where you can use Windows scheduler to spring open excel and run the code, but doing that on a user's workstation would be a terrible thing to do), running it on opening the workbook seems reasonably sensible.

It uses the PC clock in so much as it compares the dates in the table to the current date, taken from the PC clock.

The code runs down all the items in your data table and sees whether each item has pass

In the VBA Editor, open the ThisWorkbook code module from the explorer, and select "Workbook" from the left drop-down at the top of the editor window. It should create the open and closing statements for the Workbook_Open event. You can insert the code into that routine, and it'll run when the workbook is opened. Your users will have to have Macros enabled (which is generally not the default).

You might want to change the last bit to not show an alert if nothing is found to have expired.

Cal
 
Upvote 0
I'll keep you posted on how this plays out. Can't say thanks enough for your help. Maybe someday I'll be able to contribute back to this wonderful forum!

Stay tune
 
Upvote 0
Place code in where you suggested and it causes a "type mismatch" error. I have a couple of questions and maybe I can sort it out.
Here is the current code I am working with.
Changed worksheet to where the exp dates and alert dates reside.
Error occurs at this line - "dtTest = cCar.Offset(0, 1)"

dtTest = DateAdd("d", cCar.Offset(0, 3), dtTest) - Is the "d" represent Col. D in the worksheet?
There are 2 "dtTest = ". Is this a problem?


Code:
Private Sub workbook_open()
Dim cCar As Range, sh As Worksheet, strAlert As String, dtTest As Date

Set sh = ThisWorkbook.Worksheets("Reminders")
Set cCar = sh.Cells(1, 1)

Do Until cCar.Value = ""
    dtTest = cCar.Offset(0, 1)
    dtTest = DateAdd("d", cCar.Offset(0, 3), dtTest)

    If dtTest <= Date And cCar.Offset(0, 2).Value Then
        strAlert = strAlert & cCar.Value & " expired on " & Format(dtTest, "yyyy-mm-dd") & vbCrLf 'vbCrLf puts a newline (Carriage Return, Line Feed) in
    End If

    Set cCar = cCar.Offset(1, 0)
Loop

If strAlert = "" Then strAlert = "No expired cars found"

MsgBox strAlert
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,793
Members
449,048
Latest member
greyangel23

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