+ Reply to Thread
Results 1 to 35 of 35

VBA/formula to lock all other tabs

  1. #1
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    VBA/formula to lock all other tabs

    Hi

    I have tabs named from Sheet1 to sheet10. Is there a way to lock by password all tabs at once except Sheet1. Which means Sheet 1 would be unlocked at all times. when i unlock one of the other sheets by password it will remain unlocked unless i close the file.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Perhaps
    Please Login or Register  to view this content.
    Last edited by sintek; 06-09-2018 at 04:58 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi

    I might have missed something out as the vba didn't work as expexted. I should paste the vba in just sheet1 or all the tabs?

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    In a std module
    Last edited by sintek; 06-09-2018 at 07:27 AM.

  5. #5
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintek

    I did paste it in a module and the password prompt is not triggering. Sheet1 is also named correctly.

  6. #6
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi sintek

    I got it. I did not key in anything in the file which was why i was not prompted. Is there a way to promt the password upon clicking the worksheet tab as i do not want to reveal the contents of the tab without a password.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    You are going to have to hide the sheets...and then make use of code to unhide

    Please Login or Register  to view this content.
    Last edited by sintek; 06-09-2018 at 07:48 AM.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Play around with this...
    When file opens, all sheets are hidden except for Sheet1
    A Userform opens to select a sheet to unhide...
    You will then be prompt with a password = "PASSWORD"
    if entered correctly, that sheet will become visible...
    Attached Files Attached Files
    Last edited by sintek; 06-09-2018 at 08:16 AM.

  9. #9
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintek

    Can i check is there a collective way to unlock sheet 2 to sheet 10 at the same time with a single password and for the userform to close upon successfully entering the password or in other words for the userform to appear only if i press the windows image?

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Like this perhaps...

  11. #11
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintek. Yes thank you very much. the "All radio button" worked perfectly. Will you be able to let me know how it was done? I can see that there there is no change in the VBA from the previous workbook.

    Can i check is it possible to guide me on the setup of second part of my query below as well?

    at the same time with a single password and for the userform to close upon successfully entering the password or in other words for the userform to appear only if i press the windows image?

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    There is a change in code...
    Please Login or Register  to view this content.
    Please explain this in more detail...
    at the same time with a single password and for the userform to close upon successfully entering the password or in other words for the userform to appear only if i press the windows image?

  13. #13
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintek,

    Can i know which worksheet is the code pasted at. On the last attached file the codes on module1 is different from the above. I may be looking at the wrong location.

  14. #14
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    On the last attached file the codes on module1 is different from the above
    That is correct...The red part has been added...The code is housed in UserForm 1...The [UNHIDE SHEETS] button

  15. #15
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintec. a small question on the attached sheet. If i want sheet11 to be unlocked by a different password using the blue shaped button, how can i modify userform1 to unlock all except sheet11?
    Attached Files Attached Files

  16. #16
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    The code in userform1 does not "unlock" sheet11...Only sheets 2-10

  17. #17
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintec

    Can i check how can i amend the vba to input on the blue button to unlock the next sheet by another password.

    Please Login or Register  to view this content.

  18. #18
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Do you want separate code for blue button to "unlock' sheet11

  19. #19
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintec. Yes, I would like to try that. Sheets i-10 to be unlocked by the code in userform 1 and sheet 11 to be unlocked by a different code in the blue button. Kind of like 2 admins.

  20. #20
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    In attached...Click blue button...password form opens..Enter "PASSWORD"(Change in code to whatever) and press [ENTER FOR SHEET11]

    Will give you an idea...
    Attached Files Attached Files

  21. #21
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Coolio...A pleasure

  22. #22
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: VBA/formula to lock all other tabs


    Coolio ? Ah ♪ Gangsta's Paradise ♫ ‼

    Sorry, I'm out …

  23. #23
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Thank you sintec. Was practicing with the controls and it works. Can i check i saw the below 2 codes pasted. If i needed additionally sheet 2 to be visible as well, should i amend both the module and this workbook vba as to the below?

    Please Login or Register  to view this content.

    Pasted in this workbook
    Please Login or Register  to view this content.

    Pasted in module 1
    Please Login or Register  to view this content.

  24. #24
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    What are you wanting to achieve...It is unclear...
    In your post above the 1st snippet does the following:
    Ignores Sheet1 & Sheet2
    2nd Snippet...Hides all sheets except Sheet1 before closing
    3rd snippet...Does the same when userform activates

  25. #25
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    hi Sintek. I would like to ignore hiding sheet1 and sheet2 in this file.

  26. #26
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Ok got it as mentioned in post 7 i need to unhide the sheet first before running the code. Thanks

  27. #27
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Glad you got it sorted

  28. #28
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi Sintek. can i know how do i hide userform1 when i open the spreadsheet. I require it to open only when clicking the windows image.

  29. #29
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: VBA/formula to lock all other tabs


    Hi !

    Just remove the codeline from the Auto_Open procedure …

  30. #30
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi. You mean remove the removed the auto open code from module1?

  31. #31
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    no ...remove the lines...
    Please Login or Register  to view this content.

  32. #32
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi. I've removed the line userform1.show. The userform doesn't show up automatically when i open the file which i what i want but but when i click the userform1 image, the controls doensn't show up totally. I still require it to pop up upon click so that i can select which sheets to unhide.


    Please Login or Register  to view this content.
    Attached Files Attached Files

  33. #33
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Deleted image and assigned new code
    Attached Files Attached Files

  34. #34
    Forum Contributor
    Join Date
    05-16-2018
    Location
    SG
    MS-Off Ver
    2013
    Posts
    217

    Re: VBA/formula to lock all other tabs

    Hi sintek. yup that was what i needed. Can i know what was the change in code?

  35. #35
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: VBA/formula to lock all other tabs

    Nothing...Same Code
    Please Login or Register  to view this content.
    Just copied image and assigned code...deleted old image...

+ 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. Formula to total across tabs when tabs aren't made yet?
    By Joolie567 in forum Excel General
    Replies: 3
    Last Post: 06-24-2016, 01:46 PM
  2. Replies: 2
    Last Post: 02-22-2012, 10:10 AM
  3. Lock all cells except for a certain color on all tabs
    By Dragon1473 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2010, 12:43 PM
  4. Lock Sheet Tabs Using VBA
    By Joey5105 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-15-2008, 08:35 PM
  5. Lock sheet tabs option in a specific workbook
    By Tarique in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2006, 11:55 AM
  6. [SOLVED] Enhancement Request: Give us ability to lock/freeze tabs in Excel
    By Alyson Calhoun in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-01-2006, 03:55 PM
  7. Lock or Freeze Worksheet Tabs
    By Kiniski in forum Excel General
    Replies: 5
    Last Post: 01-10-2005, 04:33 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