+ Reply to Thread
Results 1 to 17 of 17

Locking all cells in a workbook

  1. #1
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Locking all cells in a workbook

    I have been having problems protecting my worksheets, using the normal manner, mainly it does not seem to work, So i came up with another idea, but cant seem to work out how to do it.

    I have a workbook with about 7 worksheets, this needs to be sent via email to our customers, and on two of the worksheets the customer can enter there comments and then email back the workbook, the problem is that i cant protect the data.

    So i was thinking is it possible to use VBA to program a function i can enter in to the toolbar that the user can lock all the cells in the whole workbox except for two columns when they finish entering in data, maybe with a password for locking it and unlocking for the original user so that they can unlock the cells for editing.

    G

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Locking all cells in a workbook

    Hi,

    Why do you think the 'normal manner' does not work? Can you explain what you're doing to protect the sheets?

    Don't forget that once you protect a sheet, by default all cells will be LOCKED apart from those you have previously set to be unlocked.

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Re: Locking all cells in a workbook

    Sorry didnt explain it to well, that is what im trying to do lock the cells that are previous unlocked, excpet for two columns.

  4. #4
    Registered User
    Join Date
    02-04-2010
    Location
    Istanbul
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Locking all cells in a workbook

    I'm not sure if this is what you did using the 'normal' way but you should be able to just:

    tools > protection > allow user to edit ranges
    new > 'select the two columns the user can edit'
    ok

    Then, when you protect the sheet the only bit which can be edited will be the area you defined. If you want, you can password protect that area:

    tools > protection > allow user to edit ranges
    'select which range' > modify > password

    Then protect the sheet.

  5. #5
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Re: Locking all cells in a workbook

    Tried all those, the problem is that the sheets within the workbook have locked areas as these contain code and or formula.

    The sheets contain formula that are locked out so that the user does not delete the information contained, So the user would enter int he required data in the given cells, i.e. the cells that are not locked, the sheets are protected at this point.

    These sheets then need to be sent to our customers for comments, but the cells where the user has entered data need to be locked so that the customer cannot change any of the details. But they have a column that they can add the comments about the presented data.

    This function needs to be controlled by the original user.

    Does this explain, I dont think a exmaple work sheet would be helpfull...

    G

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Locking all cells in a workbook

    Hi,

    I don't see what the problem is. Once the original user has entered his/her data, then they just need to click the column letter(s) and lock all the cells in that column, and ensure the column that will be used for the customers' comments has its cells unlocked.

    Rgds

  7. #7
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Re: Locking all cells in a workbook

    Thank you for your responce, That may sound the easiest way, but the worksheet is protected, cos before users had a bad habit of deleting formula and also doing stuff that confused the calculations. So for protecting the data and calculations the sheet is protected, so the user can only enter certain data and also perform certain functions.

    So i need to add to these functions a way of locking all the cells once they are ready to send it to a customer, but be able to unlock cells for alterations.

    G

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Locking all cells in a workbook

    Hi,

    I still don't see what the problem is. You have complete flexibility over which cells you lock or unlock (or protect if you wish).

    There are two concepts here. Protecting a worksheet and locking cells. By default all cells are locked, but the lock is only switched on when you choose to protect the worksheet. If you wish ALL cells to be locked so that they can't be changed by the customer, then ensure they are all locked, (they will be unless you have chosen to unlock them), and Protect the worksheet.

    If you wish the customer to be able to change certain cells then before you protect the worksheet make sure these are unlocked. Format>Cells>Security and untick the locked option.

    Furthermore when protecting the sheet you can set a password so the customer can't unlock any cells.

    Sorry if this is teaching grandmother to suck eggs but I don't know how familiar you are with all this particular functionality,

    Regards

  9. #9
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Re: Locking all cells in a workbook

    The problem here i think is that I may not be explaining it to well, I understand every thing you have explained and have used the functions.

    I have thought about this and will try and explain it in a differnt way.

    I designed a spreadsheet for my team of monitors to use, the sheet contains formule and other calculations and settings. The cell where the monitors have to enter data are unlocked, the cells that contain the formule are locked. The whole sheet is then protected so the monitor cannot delete stuff they shouldn't do.

    Once the monitor has entered there data, the sheet is normal printed off and sent to the customer, Our boses want us to change so that we are able to send the spreadsheet via email. The only problem we have is that the customer could change the data that we eneterd.

    So the monitor needs to be able to lock all the unlocked cells before sending it to the customer, well lock all unlocked cells except for two columns on different worksheets within the workbook, as these need to be availble for the customer to enter ther comments. The monitor then must be able to uinlock the workbook when it is sent back.

    I hope that explains it better...

  10. #10
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Locking all cells in a workbook

    How about setting up defined ranges relating to each set of cells that should be unlocked in each situation and then using code like this to set the protection?

    Please Login or Register  to view this content.
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  11. #11
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Locking all cells in a workbook

    Well Dom ...

    Don't you think the customer can press Alt-F11.

    What is required here is a "multiple Password" Approach.

    Here's an approach http://articles.excelyogi.com/user-p...ds/2008/12/12/

    I one sheet the passwords are kept. This sheet is protected for the outside. For "Noobs" these passwords are therefore not accesable. nevertheless They can be accesses with a little understanding of VBA, but that would be for advanced users only.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  12. #12
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Locking all cells in a workbook

    Quote Originally Posted by rwgrietveld View Post
    Well Dom ...

    Don't you think the customer can press Alt-F11.
    I'm sure they can, it was more a method of setting the cells to be locked that I was demonstating.

    A somewhat simpler seciurity approach would be to make the sub(s) private and lock the VBA project. Whoever wants to run the macros would then need the project's password.

    Dom

  13. #13
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Re: Locking all cells in a workbook

    Thanks for all your help, but i dont think any of these will help. I have figure out in that what im trying todo is protect something that is already protected.

    The only way i can think of doing, which is not reversible, is to us VBA code to unprotect the sheet, lock all the cells excpet for one column and the protect the sheet again, Again the only problem is that the monitor of that sheet would not be able to edit it again

    So how would i go about doing that, i can work out how to put a menu option in to unprotect the sheet and reprotect it, its just locking the cells and leaving a column unlocked..

    Oh thanks for the help so far, all answers ahve be saved and noted for futurte use

    G

  14. #14
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Locking all cells in a workbook

    Similar to what I posted before:

    Please Login or Register  to view this content.

    Dom

  15. #15
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Re: Locking all cells in a workbook

    I give it a try and see what happens. Could i just set the range like from a1:h2000, would that work ???

  16. #16
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Locking all cells in a workbook

    Sure, any valid range reference should work fine.

    Dom

  17. #17
    Forum Contributor
    Join Date
    01-29-2008
    Location
    Scotland
    MS-Off Ver
    2003
    Posts
    237

    Re: Locking all cells in a workbook

    Ok, that seems to work, Had to put in a warning message. Ok i have that working on one sheet, how do i do a global cell lock on all sheets in the workbook except for for two columns which are on seperate work books.. ?

    Code im using already

    Please Login or Register  to view this content.
    And is there a easy way of undoing this .... ??

    G

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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