+ Reply to Thread
Results 1 to 8 of 8

Macro to open only relevant 'password protected' tab

  1. #1
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Macro to open only relevant 'password protected' tab

    I have a file with a 'Main' sheet containing a number of countries and a series of hidden worksheets, each worksheet representing a country shown on the 'Main' tab. Conditions are as follows:
    1. Every time the file is opened, all tabs, except 'Main' should be hidden.
    2. On clicking a country in the 'Main' tab, there should be a prompt for a password (to be provided centrally but would be different for each worksheet) and on correct entry, the relevant country tab should be opened.
    3. None of the other tabs should be accessible (due to confidential nature of the data).
    4. Centrally, I should have access to all worksheets without the need for entering passwords for each of the tabs.

    I guess I could use the wsSheet.Visible = False/True to toggle between hiding and showing the sheets but am at a loss on how to make the password work. Any help will be very much appreciated.

    Attached is a file with no data but with relevant tabs.

    Merry Christmas and a Very Happy New Year 2016.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Kamboj's Avatar
    Join Date
    09-25-2014
    Location
    India
    MS-Off Ver
    2003 - 2010
    Posts
    430

    Re: Macro to open only relevant 'password protected' tab

    I have done for one sheet
    Attached Files Attached Files
    Kamboj
    _________________________________________________________________________________
    Mark the thread as SOLVED if my answer satisfy you.

  3. #3
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Macro to open only relevant 'password protected' tab

    Thanks, Kambhoj...does it mean that I will have to have as many macros as I have Countries??

  4. #4
    Valued Forum Contributor Kamboj's Avatar
    Join Date
    09-25-2014
    Location
    India
    MS-Off Ver
    2003 - 2010
    Posts
    430

    Re: Macro to open only relevant 'password protected' tab

    Yes, you can use many

  5. #5
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Macro to open only relevant 'password protected' tab

    Hi, the macro seems to work fine. However it seems like the confidentiality of data is not certain as any user can still 'unhide' the hidden tabs. If I protect the workbook to disable the unhide option, the macro fails and gives a run time error '1004': Unable to set the Visible property of the Worksheet class", as it cannot go beyond the Sheets ("worksheet name"). Visible = True

    Any help appreciated.

    Thanks

  6. #6
    Valued Forum Contributor Kamboj's Avatar
    Join Date
    09-25-2014
    Location
    India
    MS-Off Ver
    2003 - 2010
    Posts
    430

    Re: Macro to open only relevant 'password protected' tab

    if user give right password then you have to unprotect the sheet using
    sheets("your sheet").unprotect password:="your password"
    and again you can protect sheet using
    sheets("your sheet").protect password:="your password"

  7. #7
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: Macro to open only relevant 'password protected' tab

    To completely hide your sheets, please add the following code on the Workbook_BeforeClose event, this will hide and protect all unprotected and visible sheets:
    Please Login or Register  to view this content.
    This way, the user will not be able to unhide any sheet and is not able to see the list of hidden sheets.
    Hope it helps.

  8. #8
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Macro to open only relevant 'password protected' tab

    Thanks, Pip for the tip...much appreciated.

+ 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. Running workbooks.open to open pax-protected file still prompts for a password
    By karinincanada in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2015, 05:06 PM
  2. Open a password protected file with VBA
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-20-2015, 07:37 PM
  3. Open Password Protected Workbooks in a Folder Through a Macro
    By aditya88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-12-2014, 01:53 PM
  4. [SOLVED] Need macro to open excel sheet that is password protected
    By sokker23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2013, 03:04 PM
  5. [SOLVED] Password array to open all password protected workbook in a folder
    By rename in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-07-2012, 05:06 AM
  6. Replies: 4
    Last Post: 11-20-2009, 06:18 AM
  7. vba macro open password protected workbook
    By Ray in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2006, 11:15 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