Excel - A macro to protect a workbook
On May 25,2022 by Tom RoutleyIssue
I want to protect my Excel workbook and the spreadsheets it contains.
The application I developed with Excel, contains menus, and buttons and graphics that change depending on the responses of a user (mcq). If I do not touch anything at the basic protection (everything is protected) and the user can only view data without interaction. If I unprotect certain cells, such as table cells, the user not only modify the data, but also objects like buttons, and that the main problem.
Solution
Try this:
You must unlock your objects (adapt accordingly):
Range("K17").Select Selection.Locked = False Selection.FormulaHidden = False
This protect your sheet:
ActiveSheet.Protect DrawingObjects: = True, Contents: = True, Scenarios: = True
If you want to unprotect it:
ActiveSheet.Unprotect
Thanks to 0seb0 for this tip.
Article Recommendations
Latest articles
Popular Articles
Archives
- November 2024
- October 2024
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- January 2024
- December 2023
- November 2023
- October 2023
- September 2023
- August 2023
- July 2023
- June 2023
- May 2023
- April 2023
- March 2023
- February 2023
- January 2023
- December 2022
- November 2022
- October 2022
- September 2022
- August 2022
- July 2022
- June 2022
- May 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- October 2021
- September 2021
- August 2021
- July 2021
- January 2021
Leave a Reply