Home

Changing default elements when locking a spreadsheet

%3CLINGO-SUB%20id%3D%22lingo-sub-844284%22%20slang%3D%22en-US%22%3EChanging%20default%20elements%20when%20locking%20a%20spreadsheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-844284%22%20slang%3D%22en-US%22%3E%3CP%3EHello!%20At%20my%20job%2C%20we%20used%20to%20manually%20protect%20spreadsheets%20to%20prevent%20cells%20with%20calculations%20from%20being%20changed.%20When%20manually%20protecting%2C%20we%20would%20check%20all%20of%20the%20elements%20in%20the%20Protect%20Sheet%20box%20to%20allow%20users%20of%20the%20worksheet%20to%20do%20all%20of%20those%20things%20with%20the%20spreadsheet%20protected%3B%20basically%20they%20could%20do%20everything%20except%20change%20the%20formulas%20within%20the%20locked%20cells.%20With%20this%20being%20forgotten%20more%20than%20once%2C%20I%20found%20a%20way%20to%20enter%20some%20VBA%20Coding%20into%20the%20spreadsheet%20to%20auto-lock%20upon%20save%20and%20close.%20Is%20there%20a%20way%20to%20either%20edit%20my%20coding%20or%20edit%20the%20protection%20settings%20for%20Excel%20so%20that%20these%20elements%20are%20automatically%20checked%20when%20the%20spreadsheet%20is%20automatically%20protected%20upon%20saving%20and%20closing%3F%20Thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-844284%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EProtection%20Settings%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-844326%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20default%20elements%20when%20locking%20a%20spreadsheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-844326%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F405988%22%20target%3D%22_blank%22%3E%40kndusek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20%3CSTRONG%3Eworksheet.protect%3C%2FSTRONG%3Emethod%20has%20a%20whole%20raft%20of%20properties%20it%20is%20possible%20to%20set%20from%20VBA%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3Eworksheet%3C%2FEM%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSTRONG%3EProtect%3C%2FSTRONG%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CEM%3EPassword%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EDrawingObjects%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EContents%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EScenarios%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EUserInterfaceOnly%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowFormattingCells%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowFormattingColumns%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowFormattingRows%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowInsertingColumns%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowInsertingRows%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowInsertingHyperlinks%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowDeletingColumns%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowDeletingRows%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowSorting%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowFiltering%3C%2FEM%3E%3CSPAN%3E%2C%20%3C%2FSPAN%3E%3CEM%3EAllowUsingPivotTables%3C%2FEM%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CFONT%20face%3D%22Segoe%20UI%2CSegoeUI%2CSegoe%20WP%2CHelvetica%20Neue%2CHelvetica%2CTahoma%2CArial%2Csans-serif%22%20color%3D%22%23b00000%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Fexcel.worksheet.protect%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Fexcel.worksheet.protect%3C%2FA%3E%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
kndusek
Occasional Visitor

Hello! At my job, we used to manually protect spreadsheets to prevent cells with calculations from being changed. When manually protecting, we would check all of the elements in the Protect Sheet box to allow users of the worksheet to do all of those things with the spreadsheet protected; basically they could do everything except change the formulas within the locked cells. With this being forgotten more than once, I found a way to enter some VBA Coding into the spreadsheet to auto-lock upon save and close. Is there a way to either edit my coding or edit the protection settings for Excel so that these elements are automatically checked when the spreadsheet is automatically protected upon saving and closing? Thanks!

1 Reply

@kndusek 

The worksheet.protect method has a whole raft of properties it is possible to set from VBA

 

worksheet.Protect (Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables)

 

https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet.protect

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
38 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies