+ Reply to Thread
Results 1 to 14 of 14

Protect/Unprotect sheets

  1. #1
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Protect/Unprotect sheets

    Hello,

    I found these two codes for unprotecting/protecting sheets. How can I combine these codes to build only one macro that would do - If sheets unprotected Then password and Protect OR If sheet protected Then password and Unprotect ?

    Code:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Protect/Unprotect sheets

    You may try:

    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Protect/Unprotect sheets

    Here is a very very simple example:

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

  4. #4
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Protect/Unprotect sheets

    Hi Izandol,

    Your code works, but I am now trying to achieve same with toggle button, I think It would look better.

    I want toggle button to be True If sheets are protected. If you click again on toggle button and don't type password or type incorrect password then I would like toggle button to be again True, and stay like that - until I type correct password.


    this is code, but It not working properly :

    Please Login or Register  to view this content.
    I know I'm annoying, but If someone can do this, I would appreciate very much.

  5. #5
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Protect/Unprotect sheets

    Sniper thanks,

    but I prefer to unprotect/protect with passwords on one toggle button.

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Protect/Unprotect sheets

    You may try:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    08-27-2009
    Location
    South Africa
    MS-Off Ver
    Office 2010
    Posts
    217

    Re: Protect/Unprotect sheets

    Ok, just and you would like to put in the password? Did Izandol cover your question?
    If your Dreams don't scare you......They are not big enough

    If you like my answer don't forget to click on the *

  8. #8
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Protect/Unprotect sheets

    Izandol thanks,

    that's exactly what I wanted

  9. #9
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Protect/Unprotect sheets

    Quote Originally Posted by Sniper View Post
    Ok, just and you would like to put in the password? Did Izandol cover your question?
    Izandol answered my question, thanks for help although !

  10. #10
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Protect/Unprotect sheets

    Izandol, sorry to bother again,

    but I copy that toggle button from my first sheet on every new sheet. And when I protect cells in one sheet, toggle button stays True only on that sheet, on other sheets It stays as when copied. How can I fix that, don't want to delete toggle button on new sheets ?

    Also noticed that If I don't enter password to protect, It also protects cells and toggle button goes True. And then If you click again, It unprotects everything....
    Last edited by Lukael; 03-17-2014 at 07:05 PM.

  11. #11
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Protect/Unprotect sheets

    If you wish to change protection for all sheets it will be simpler to use menu instead of button on every sheet.

  12. #12
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Protect/Unprotect sheets

    I have one Userform but this button wouldn't be quite good in terms of Userform's purpose, that's why I wanted button to be on sheets.

    Did you mean like adding cmdbutton to open menu and then perform code ? I also noticed that code works only in sheet, If I put it in module or Workbook buttons doesn't respond...

  13. #13
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Protect/Unprotect sheets

    I mean button on menu bar (Excel 2003 and before)/Ribbon (Excel 2007 and after).

  14. #14
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Protect/Unprotect sheets

    Ok then, looks like this is really best option. But I'll keep digging in code, maybe I find a solution in VBA...

    Thanks for all help, you really helped me !

+ 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. [SOLVED] Macro to Unprotect sheets-unlock range of cells-protect sheets
    By jrace in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2013, 10:45 AM
  2. Unprotect the multiple sheets and protect them again
    By itisalikhan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2012, 01:12 PM
  3. [SOLVED] protect/unprotect all sheets
    By wayneg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-03-2012, 08:20 AM
  4. [SOLVED] Password protect and unprotect all sheets EXCEPT two named sheets
    By Ducatisto in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2012, 05:43 AM
  5. protect/unprotect all sheets
    By roos in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2006, 06:50 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