Hi all, it's been a while since I used this forum but it's that time again where head scratching doesn't help me progress any more.
I've made a simple excel file that has a list of classes, and whether or not a homework is due in. What I wanted to do is create a file that, upon opening, displays a message saying which classes have a homework due in on that day (or whether it's overdue for whatever reason).
Initially, my code was the following:
![]()
Sub Workbook_Open() For Each cell In Sheets("HW").Range("H2:H9") If cell.Value = "YES" And cell.Offset(0, -2).Value = "No" Then MsgBox cell.Offset(0, -7).Value & " HW is due in today" ElseIf cell.Value = "OVERDUE" Then MsgBox cell.Offset(0, -7).Value & " HW is OVERDUE" End If Next End Sub
What is going on here is that the macro checks to see if there is a "yes", "no" or "overdue" in the "is it due today" column in my worksheet, and then brings up the corresponding class name with the required text.
However, although it works, it gives me individual message boxes for each message. Is there a simple way of merging all outcomes into one message box? I tried assigning variables and having each iteration output the outcome into that variable, with the final message box being composed of all the required variables...however...that leads to the problem of having an unknown number of variables at the start, because I can't predict how many variables the macro should assign at the start. Or am I thinking about it the wrong way? One other suggestion is that to have the maximum number of variables assigned (as many classes as I teach, if ever the day comes where they all need to hand homework in haha!), and simply have no outcome assigned to a variable if there isn't any corresponding homework due in?
Thanks in advance
Bookmarks