+ Reply to Thread
Results 1 to 10 of 10

Open Userform when you close a spreadsheet

  1. #1
    Registered User
    Join Date
    11-24-2006
    Location
    Bristol, UK
    Posts
    34

    Open Userform when you close a spreadsheet

    Hi guys

    I've got a 'Control Panel' spreadsheet which is all based on UserForms. When a user clicks a particular button, it opens one of many separate 'Regional' sheets which they work in.

    When the user closes the 'Regional' sheet, I would like the 'Control Panel' sheets userforms to show again. However I can find no way of doing this as it simply switches back to the 'Control Panel' sheet without loading the forms (as I had to hide the 'Control Panel' useforms to give them access to the 'Regional' sheet).

    Any help would be greatly appreciated

    Cheers

    Nick

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Try this on the controlpanel sheet

    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    11-24-2006
    Location
    Bristol, UK
    Posts
    34
    Quote Originally Posted by mudraker
    Try this on the controlpanel sheet

    Please Login or Register  to view this content.
    Thanks Mudraker. Already tried that and it doesn't work; I tried putting msgboxes in all the Worksheet_Activate, Workbook_SheetActivate etc etc subs to see if any of them appeared when the 'Regional' sheet closed. Unfortunately none of them did.

    Any other ideas?

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    What do you mean by 'Regional' closed?

    How does a user close the sheet?

  5. #5
    Registered User
    Join Date
    11-24-2006
    Location
    Bristol, UK
    Posts
    34
    I have two completely separate workbooks, ControlPanel and Regional. The ControlPanel consists of various user-forms, which ultimately lead to ControlPanel being hidden and the Regional workbook being loaded.

    When a user closes the Regional workbook (literally quits out of it), ControlPanel comes back (being the remaining workbook open). What I can't get it to do is to run/show the ControlPanel userforms when it switches back to ControlPanel.

    As mentioned, I've tried putting msgboxes in various subs to see if they are called when Regional closes and ControlPanel is reverted to, but it doesn't seem to trigger anything.

    Thanks for your time, it seems to me that it's something that VBA should be triggering (eg. Worksheet_Activate sub) but isn't.

    Cheers

    Nick

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Have you tried a Private Sub Workbook_Activate() macro.

    When I have 2 books open & close the active one the other book's Private Sub Workbook_Activate() is triggered

    Is it possible you have turned off event triggers by using
    Please Login or Register  to view this content.
    And not turned them on by using
    Please Login or Register  to view this content.
    It also helps when describing problems etc that you do not use sheet or worksheet when you shold use book or workbook

  7. #7
    Registered User
    Join Date
    11-24-2006
    Location
    Bristol, UK
    Posts
    34
    Thanks for your help Mudraker and apologies for the sheet/workbook mix-up.

    The problem seems to be that I'm closing the Regional workbook with a command button. When it reverts to the ControlPanel workbook it does not run the Workbook_Activate sub. If I simply close the Regional workbook it does run the Workbook_Activate sub.

    I've checked for EnableEvents and for DisplayAlerts and they're both set to true. The macro that closes the workbook is very simple and as far as I can see should not stop the Workbook_Activate from running:

    Please Login or Register  to view this content.
    Any idea why the macro stops it running?

    Kind regards and many thanks

    Nick

  8. #8
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    The problem may be because you are running a macro that closes a book at the same time that the ControlPanel book becomes active.

    Try this - I am sure this suggestion will work (fingers crossed)

    The Regional workbook close_nosave macro runs a macro on the Controlpanel workbook which closes the regional sheet and then displays the form.

    In your controlpanel workbook place this code in a normal module sheet
    Please Login or Register  to view this content.
    Modify your Regional workbook close_nosave macro

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-24-2006
    Location
    Bristol, UK
    Posts
    34
    Excellent, thanks. Seems so obvious when you look at it! Much appreciated.

  10. #10
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    I'm glad I could help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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