+ Reply to Thread
Results 1 to 3 of 3

Password protect/unprotect 11 out of 12 tabs when i edit

  1. #1
    Registered User
    Join Date
    03-01-2014
    Location
    Stoke on Trent
    MS-Off Ver
    Excel 2019
    Posts
    31

    Password protect/unprotect 11 out of 12 tabs when i edit

    Hi Guys, i have 12 tabs(worksheets) one for each month. i use the Jan tab(worksheet) to edit and then a macro to update the other 11 worksheets. what i would like to add is at the start of the macro to update i wanted to add code to unprotect the 11 worksheets i have password protected and once it has updated the worksheets to password protect the 11 worksheets again....is this possible. i have attached the macro i am using at the moment

    updateTickSheets Macro
    '
    Sub updateTickSheets()
    Sheets("Jan").Select
    Rows("2:47").Select
    Selection.Copy
    Sheets("Feb").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Mar").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Apr").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("May").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Jun").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Jul").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Aug").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Sep").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Oct").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Nov").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Dec").Select
    Rows("2:47").Select
    Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
    , SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("G2").Select
    Sheets("Jan").Select
    Range("G2").Select
    End Sub

  2. #2
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: Password protect/unprotect 11 out of 12 tabs when i edit

    Please use code tags when posting code to the forum (forum rule 2)

    Your code is not very readable and has way to much code..
    It is relative easy to unprotect and protect sheets before and after code needed for the worksheet

    I think your whole code can be reduced to
    (this is untested ofcourse as there is no testfile
    Please Login or Register  to view this content.
    if you decide to keep your own code this is how you need to add the unprotect and protect lines on each part (I only do one)

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-01-2014
    Location
    Stoke on Trent
    MS-Off Ver
    Excel 2019
    Posts
    31

    Re: Password protect/unprotect 11 out of 12 tabs when i edit

    Thanks for your quick response and everything is running ok after the mod

+ 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. Unprotect sheet and re-protect with new password
    By nwb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2014, 04:47 AM
  2. Add unprotect and protect password to Macro
    By Vicious00013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2014, 11:52 PM
  3. VBA to Unprotect (w/ password), Unhide, Hide, and Protect (w/ password)
    By pger34 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-14-2012, 12:35 PM
  4. VB protect & unprotect worksheet with password
    By Launchnet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-02-2008, 05:16 AM
  5. Macro to protect/unprotect with password
    By Cam in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2005, 06:05 PM
  6. Please help!!! Using code to password-protect and unprotect...
    By Hawk in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2005, 06:05 PM
  7. [SOLVED] Re: Password - Protect, UnProtect
    By Jeff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2005, 04:06 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