+ Reply to Thread
Results 1 to 6 of 6

Macro to Unprotect Sheet, Paste then Protect Sheet

  1. #1
    Registered User
    Join Date
    03-15-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    27

    Macro to Unprotect Sheet, Paste then Protect Sheet

    Looking for some help, I want a sheet to copy and paste into another worksheet, I have that code and its working fine, but what I also want to do is for the sheet to be protected,so the code would be, copy, unlock, paste, lock, save.

    Here is the code I have so far. I know i have to include ActiveSheet.Unprotect "passowrd" ActiveSheet.Protect "password", but I dont know where to include that last part of the code.

    Thanks.



    Please Login or Register  to view this content.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro to Unprotect Sheet, Paste then Protect Sheet

    It would basically look like this:
    Please Login or Register  to view this content.
    Replace capitalised parameters to suit.

    You don't need to do all that selecting, that's just slowing stuff down.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to Unprotect Sheet, Paste then Protect Sheet

    @ Olly,

    Hello Olly,

    I like your reply, although your Code assumes Named Ranges, which I am not so sure the OP may have.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro to Unprotect Sheet, Paste then Protect Sheet

    The OP's source and target ranges weren't clear - so I tried to show some GENERIC code, and make clear that the capitalised bits need replaced with specific sheet names / range addresses

    Of course, named ranges would work beautifully, but replacing Range("SOURCERANGE") with Range("A3:Y3") would work equally well.

    Thanks for clarifying!

  5. #5
    Registered User
    Join Date
    03-15-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    27

    Re: Macro to Unprotect Sheet, Paste then Protect Sheet

    Quote Originally Posted by Olly View Post
    The OP's source and target ranges weren't clear - so I tried to show some GENERIC code, and make clear that the capitalised bits need replaced with specific sheet names / range addresses

    Of course, named ranges would work beautifully, but replacing Range("SOURCERANGE") with Range("A3:Y3") would work equally well.

    Thanks for clarifying!
    Thanks Olly, it works

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to Unprotect Sheet, Paste then Protect Sheet

    @ Olly,

    Thank you for not taking any offence to my comment!

    With your reply, you have actually clarified everthing, thank you.

    @ tokyojo1,

    Olly has provided you with a very good solution, which you seem to be satisfied with.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, since you are relatively new to the forum, I would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which you have been helped. This adds to the reputation of the person who has taken the time to help you.

    Thanks.

+ 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. Macro to unprotect sheet - run macros - then unprotect sheet is not working
    By AnnieBrownTX in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2012, 06:59 PM
  2. Macro to unprotect sheet --> unlock cells --> protect again
    By hrhittn23 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-02-2011, 07:00 AM
  3. Macro to Unprotect Sheet, Sort then Protect Sheet
    By lisamckinney in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2010, 05:23 PM
  4. protect then unprotect sheet
    By dealer in forum Excel General
    Replies: 4
    Last Post: 10-19-2010, 12:54 PM
  5. Unprotect and Protect sheet within macro
    By John F in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-11-2005, 01: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