+ Reply to Thread
Results 1 to 8 of 8

Message Box that auto closes

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    53

    Message Box that auto closes

    I'm using Windows 10 Enterprise, Excel/Microsoft 365 Apps for enterprise, Version 2105 (Build 14026-20246)
    I'm a novice (at best) VBA user. I mostly google and borrow and modify as needed, but trying to learn too.

    I have a very large Excel file with numerous tabs.
    For this, I'm focused on just 2 of the tabs.

    Tab 1: "Weekly Review"
    Tab 2: "Weekly Pivots"
    Tab 1 has 4 cells that can be changed: F1, D4, D5, K4 - these are also named cells as follows:
    Fld_SelectWeeklyPullRangeType,Fld_WeekStartDateSelect,Fld_WeekEndDateSelect,Fld_SelectLatestNoOfWeeks.
    Tab 1 displays 6 graphs (these are pivot graphs), these graphs are driven by the pivot tables located on Tab 2.
    When any one of these 4 cell values change, I'm auto refreshing the 6 pivot tables on Tab 2.
    Tab 2 will be hidden once this is fully working.

    On Tab 1 I have the following code that does the auto refresh to the 6 pivot tables on Tab 2.
    This code runs as expected refreshing all 6 pivots tables on Tab 2 and the graphs on Tab 1 auto update once the pivot tables are done refreshing.

    Here's my current VBA code...
    Please Login or Register  to view this content.
    During the refresh process, the mouse cursor kind of "blinks" a lot and the lower left of the screen flashes "Ready" off/on numerous times.
    The refresh takes on average 10-17 seconds to complete.

    What I'm wanting to do is the following so that the user is FULLY aware that the update is in process:
    1. When the above code is kicked off, I would like a custom message box to appear that says "Update in process. Please do not leave this page or click any buttons. This message will automatically disappear in 15 seconds." If possible I'd like to NOT have any buttons on this pop-up (i.e. No "OK", "YES", "NO", etc).
    2. I would like an auto timer for Message 1, that disappears in X seconds (I'll probably start with 15 seconds and test it several times to get this exactly where it needs to be).
    3. Then I'd like a 2nd auto message that pops-up (replacing the first message) that says "Refresh is complete. Click OK to close this message." (then 1 button that says "OK" that will close the message.

    I found the following code online and tried inserting it in my above code, but I broke my existing code (because I don't understand "sub" lines, where things stop and start and need inserted, etc.) The following is for only 1 message, but I thought I'd share this in case it's headed in the right direction?

    Please Login or Register  to view this content.

    Thank you for taking a look!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Message Box that auto closes

    You could try Application.ScreenUpdating = False before your code, and set it back to True afterwards.

    See this example of an auto closing message box: https://docs.microsoft.com/en-us/off...-a-message-box
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    53

    Re: Message Box that auto closes

    Appreciate the response. I'll mention again that I'm a real novice here so...

    1. I have no idea what the Application.ScreenUpdating = False is intended to do, where it gets added, why it gets added, how or why I would set it back to True, or literally anything. Would love to know more details about this.
    2. The message box was helpful (to a degree). Again, being a novice, I inserted this code as shown next. So I get the Msg box for 15 seconds and the refreshing isn't occurring while the msg box is displayed on screen. I need the msg box to pop-up right away, then the refreshing is occurring for say 15 seconds, and then the msg box goes away. Also, I was also hoping to NOT have the OK button - is that possible? When I put the msg box after the refreshing then it refreshes for like 15 seconds, then the msg box pops up for 15 seconds and then it goes away.

    How do I make this a seamless all in one (msg box, refreshing in background with msg box still showing, then msg box goes away)?

  4. #4
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    53

    Re: Message Box that auto closes

    Sorry, here's the code as it currently sits:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    53

    Re: Message Box that auto closes

    I've tried moving "parts" of the timed msg box to both sides of the refresh part of the code and this either causes it not to work at all, or it doesn't do both things, or it does them separately. I've tried numerous layouts. Here's my latest that still isn't right.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    53

    Re: Message Box that auto closes

    Reaching out to see if anyone can help me wrap this up.

  7. #7
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Message Box that auto closes

    Not sure about using WScript. I feel it should be possible using a custom UserForm. See attached sample. If you export/import the userform from the attached workbook, you *might* be able to re-structure your code like this:

    Please Login or Register  to view this content.
    I can't test it however because I don't have your file.

    WBD
    Attached Files Attached Files
    Office 365 on Windows 11, looking for rep!

  8. #8
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    53

    Re: Message Box that auto closes

    WBD - it works perfectly. Once again you save the day!!!! Thank you so much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. This macro closes firefox browser. I need a modification that closes Chrome
    By emymeeky in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-27-2017, 12:48 PM
  2. [SOLVED] Code closes all but active workbook, also closes personal...
    By fourmurphys in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-24-2016, 03:43 PM
  3. [SOLVED] message box pop up within userform, clicking ok closes userform
    By teacher_rob in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-22-2012, 12:10 PM
  4. How to popup a message when excel closes
    By Alice21 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-15-2011, 10:44 AM
  5. Auto-open macro closes workbook - how do I access its contents?
    By audax in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2009, 02:13 PM
  6. message box that closes its self
    By raw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-02-2007, 03:27 PM
  7. Auto run macro when excel closes
    By ResulG in forum Excel General
    Replies: 3
    Last Post: 11-27-2006, 01:15 PM

Tags for this Thread

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