0
Thanks

A few words of thanks would be greatly appreciated.

Excel - A macro to protect a workbook



Issue


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.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Published by . Latest update on by deri58.

This document, titled "Excel - A macro to protect a workbook," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments