+ Reply to Thread
Results 1 to 5 of 5

Disable exit on selected tabs

  1. #1
    Registered User
    Join Date
    11-06-2013
    Location
    NC
    MS-Off Ver
    Excel 2007
    Posts
    42

    Disable exit on selected tabs

    I have a workbook with 3 tabs. The first tab is called Log-In, the 2nd tab is called "Unverified", and the third tab is called "Verified". I need to be able to force the user to use an "Exit" button I have created instead of being to close the worksheet with the Close "X" on the "Unverified" and "Verified" tabs. The Exit button runs a macro that formats and saves the worksheet.

    However I need to allow the close function to occur on the tab named Log-In. I have created the following macro and placed the code in This Workbook. Unfortunately I am a novice at VBA and despite my efforts it does not work.

    Can anyone help?

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Disable exit on selected tabs

    Hello Randy,

    The following code placed in the "Workbook" module should do the job for you:-

    Please Login or Register  to view this content.
    It should leave your "Log-In" sheet to close as per normal. The other two sheets will be blocked from the normal "close" procedure with your Exit button taking over from there.

    I hope that this helps.

    Regards,
    vcoolio.

  3. #3
    Registered User
    Join Date
    11-06-2013
    Location
    NC
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Disable exit on selected tabs

    This worked perfectly. Thanks much!

  4. #4
    Registered User
    Join Date
    11-06-2013
    Location
    NC
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Disable exit on selected tabs

    vcoolio,

    Is there also a way of preventing the user from using the "Save" or "Save-As" Excel functions for all tabs but the "Log-In" page?

    Thanks,

    Randy

  5. #5
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Disable exit on selected tabs

    Hello Randy,

    I think that the above code pretty well covers it. Save, Save As... is part of the Close(X) function so the above code covers the entire work book except the exempt sheets (such as "Log-In").

    The following code (and there are a number of variations for such a function) would work also:-


    Please Login or Register  to view this content.
    However, if you have a look at the following thread:-

    http://www.excelkey.com/forum/viewtopic.php?f=3&t=1620

    you may begin to understand the complexities of such a request and the "round-a-bout" issues that can arise.

    Keep it simple, Randy.

    Cheerio,
    vcoolio.

+ 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. Exit macro when no file is selected for open
    By fblaze in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2014, 04:08 PM
  2. Exit sub if even row selected in specific column
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-03-2014, 02:09 PM
  3. When Cancel is selected, I want to exit sub
    By Rubert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 05:02 PM
  4. Disable Selecting Tabs
    By faboualfa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2009, 04:08 PM
  5. Auto save on exit selected data sheets, instead of whole project?
    By Bafa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2008, 01:38 PM

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