+ Reply to Thread
Results 1 to 6 of 6

How to lock the cell ranges automatically to protect entire workbook?

  1. #1
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    How to lock the cell ranges automatically to protect entire workbook?

    Hi friends,

    Good morning!

    I need a little revision to fully protect the workbook. At present I have unlocked some cell ranges for data entry which I want to lock after expiry date. However it's very laborious job to manually lock all the cell ranges to protect the workbook fully to prevent any change after expiry date.

    Any help will be appreciated.

    Thanking you,
    Attached Files Attached Files
    Sincerely,

    mso3

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: How to lock the cell ranges automatically to protect entire workbook?

    Hi, mso3,

    depending on if you want to lock all cells on the sheets try
    Please Login or Register  to view this content.
    for the entire sheet or
    Please Login or Register  to view this content.
    only for the area with data/formulas.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: How to lock the cell ranges automatically to protect entire workbook?

    Hi Holger,

    Good morning!

    I'm getting compile error '1004 the password is not correct' on the line
    Please Login or Register  to view this content.
    on the first piece of code for entire workbook. The cells are locked after expiry date and the workbook is protected by the new password. It's correct but the error occurs when I reopen the workbook. At this time it tries to unprotect the workbook by old password which is not applicable after expiry date. See the file attached and suggest me a correction.

    Thank you.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: How to lock the cell ranges automatically to protect entire workbook?

    what i notice is that you have set two different Passwords on the code - i believe is causing the error

    Please Login or Register  to view this content.
    don't worry, there's a lot of people that are far more confused than you
    but if you liked what i suggested. Click for me the "Add Reputation" - that way, we'd be both happy.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: How to lock the cell ranges automatically to protect entire workbook?

    Hi, mso3,

    letīs add an error handler to the code in Workbokk_Open:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: How to lock the cell ranges automatically to protect entire workbook?

    Hi Holger,
    Excellent! Now It's working absolutely fine as per my requirement.

    I sincerely appreciate you and your kind efforts to solve the problem.

    Thanking you,

    Have a nice day!

+ 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 password protect a workbook and lock and unlock it with a keystroke command
    By justdeepee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2014, 07:00 PM
  2. Time lock an entire workbook - even unprotected cells
    By AlexanderTheAverage in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2012, 01:57 PM
  3. Automatically Lock (protect) cell ranges
    By habesha in forum Excel General
    Replies: 0
    Last Post: 06-08-2011, 01:07 AM
  4. Protect entire workbook
    By dwarford101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2010, 06:07 AM
  5. Lock and password protect only cells with formulas on all sheets in a workbook
    By steve in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-10-2006, 03:29 AM

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