+ Reply to Thread
Results 1 to 6 of 6

I want to copy a protected sheet.. and keep it protected?!?

  1. #1
    Registered User
    Join Date
    07-28-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Excell 2008 for Mac version 12.0 (071130)
    Posts
    2

    Question I want to copy a protected sheet.. and keep it protected?!?

    hi all
    I have a worksheet I use to balance a cash register in a little retail store. We have a point of sale register but we use excell to double check all the figures and provide a running record for accounting purposes.
    Each day we use a template worksheet which has a number of calculations set up to add up the takings in cash, credit cards etc.
    There are a number of unprotected cells, where we can enter numbers for the amounts taken in various transactions, and then a number of cells with calculations set up to work with this data.
    I want to protect the calculation cells so they cannot be overwritten by accident as we enter the daily data in. I have protected these cells by by selecting them, and checking the 'protect cells' checkbox in the format cells dialog, and then protecting the sheet via the tools menu.
    BUT!
    at the end of each day I want to copy the worksheet and reset the editable values so we can do it all again the next day. I do this by right clicking on the sheet tab at the bottom of the screen, picking move or copy, ticking the 'create a copy' checkbox, and renaming the resulting duplicate worksheet.
    however when I do this I find that my new worksheet is NO LONGER PROTECTED. I have to go back to tools>protection>protect worksheet and add a new password.
    Is there a way I can duplicate my sheet and retain these protection settings?
    I'm reasonably savvy with excell but I've been trying to work this out for a while and it is beyond me. If there are any clever nerds out there who can help me I would REALLY appreciate it!

    thanks in advance

    dan

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: I want to copy a protected sheet.. and keep it protected?!?

    Please Login or Register  to view this content.
    Not in excel, so not tested.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: I want to copy a protected sheet.. and keep it protected?!?

    You shouldn't need to unprotect the sheet to copy it. Bothe the routines below work and leave both sheets protected with the same password.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    07-28-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Microsoft Excell 2008 for Mac version 12.0 (071130)
    Posts
    2

    Re: I want to copy a protected sheet.. and keep it protected?!?

    thanks for the responses guys! awesome.
    I couldn't get nathansavs code to work - this is probably my inexperience with vba macros...
    TMS's second option works well in a very simple test spreadsheet with two data cells and a locked calc cell (adding the 2 data cells together) - but when I try it in a version of my actual .xlsb i get a Run-time error '9': Subscript out of range...?
    When I debug the code this line is highlighted:
    Set ws = Sheets("Sheet1")
    could this be because we name each tab with the day and date? Sorry if this makes things more complicated!
    what would be truly awesome is if there was a way we could add to the code to prompt a dialog box asking the user to name the new duplicate worksheet! too hard?

    love to hear your helpful thoughts!
    thanks again

    dan

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: I want to copy a protected sheet.. and keep it protected?!?

    If you don't have a Sheet called "Sheet1", that is why you are getting a subscript out of range ... "Sheet1" is the index for the worksheets collection.

    If the sheet you want to copy is selected, so it is the ActiveSheet, so you could just say,
    Please Login or Register  to view this content.
    You should be able to "build" the sheet name for the copied worksheet based on whatever standards you adhere to, for example, using the current date or date +1.

    If you ask for the user to provide the name, you would need to validate it and ensure that it was consistent

    Regards, TMS

  6. #6
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: I want to copy a protected sheet.. and keep it protected?!?

    Quote Originally Posted by dan_native View Post
    I want to protect the calculation cells so they cannot be overwritten by accident as we enter the daily data in. I have protected these cells by by selecting them, and checking the 'protect cells' checkbox in the format cells dialog, and then protecting the sheet via the tools menu.
    Sounds to me like you don't really need to use Protect Cells.

    You can spoof the same effect with Data Validation: just set it to throw up a warning anytime the user tries to input over the existing fomula.

    Data Validation carries over when the tab is copied, so there's no need for a VBA solution.

+ 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. vba changing sheet tab color when it was protected/not protected
    By mcmunoz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2013, 05:39 AM
  2. [SOLVED] Copy protected sheet to a NEW workbook that is not protected
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-14-2012, 11:50 AM
  3. Copy and paste insert rows with protected cells in protected worksheet
    By excel_gecko in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-24-2012, 05:50 PM
  4. Delete rows in a protected sheet with protected cells
    By Maranwe in forum Excel General
    Replies: 7
    Last Post: 10-31-2011, 08:12 AM
  5. Protected Sheet not protected from Copy Paste
    By twistedsymphony in forum Excel General
    Replies: 4
    Last Post: 04-19-2010, 05:37 PM

Tags for this Thread

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