Results 1 to 8 of 8

Merging all outputs into one message box

Threaded View

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    25

    Merging all outputs into one message box

    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
    Last edited by DanielPodo; 11-11-2015 at 07:23 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. one function two outputs.
    By Richard N in forum Excel General
    Replies: 1
    Last Post: 04-22-2013, 12:18 PM
  2. Merging: displaying which sheet data comes from when merging sheets
    By zed commander in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-12-2012, 12:20 PM
  3. Merging cells/merging cell content.
    By rhintintin in forum Excel General
    Replies: 3
    Last Post: 09-23-2010, 10:42 AM
  4. Arranging Outputs
    By VBA Beginner in forum Excel General
    Replies: 1
    Last Post: 02-09-2007, 07:39 PM
  5. Replies: 1
    Last Post: 01-07-2006, 05:00 AM
  6. Replies: 0
    Last Post: 10-17-2005, 04:05 PM
  7. Disable alert message when merging cells??
    By yung in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2005, 11:06 PM
  8. Help on macros and outputs
    By EARTHWALKER in forum Excel General
    Replies: 2
    Last Post: 01-11-2005, 09:46 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1