Code To Prevent Editing & Selecting Of Range Worksheet

  • Hi All,


    I have the following code that Ger Plante very kindly helped me with which, depending on whether there is an 'x' by someone's name in a list, creates a new workbook, copies some information to it and saves it before moving on to the next 'x'.


    http://www.ozgrid.com/forum/showthread.php?t=103272



    Could anyone please tell me how I can modify the code such that any cells in the range "b1:b504" in Sheet1 of the the new workbook can't be selected or edited without a password....I have tried unsuccessfully using Protect but am not sure how to get vba to set it to specific cells and determine exactly what is allowed in those cells.


    Thanks,


    Jon

  • Re: Prevent Editting And Selecting Of Range In Newly Created Workbook


    Try :

  • Re: Prevent Editting And Selecting Of Range In Newly Created Workbook


    Hi Daniel,


    Thanks for your help.


    This does lock the cells I want but doesn't stop me selecting or editting them.


    Any ideas?


    Jon

  • Re: Prevent Editting And Selecting Of Range In Newly Created Workbook


    You should not be able to edit the cells if they are locked and the sheet protected. Is this the case or do I miss something ? To prevent the selection of locked cells, add :

    Code
    ActiveSheet.EnableSelection = xlUnlockedCells


    after :

    Code
    ActiveSheet.Protect , Password:="whatyouwant"
  • Re: Prevent Editing And Selecting Of Range In Newly Created Workbook


    That's exactly what I was after. Thanks, your help is greatly appreciated.


    FYI, the final version of the code was:


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!