SOLVED
Home

Prevent Unfreezing in a Shared Workbook Excel 2016

%3CLINGO-SUB%20id%3D%22lingo-sub-757064%22%20slang%3D%22en-US%22%3EPrevent%20Unfreezing%20in%20a%20Shared%20Workbook%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-757064%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20Morning%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20Shared%20Workbook%20that%20I%20need%20to%20prevent%20others%20users%20from%20being%20able%20to%20Unfreeze%20Panes.%20I've%20already%20Protected%20the%20Sheet%20to%20and%20Locked%20specific%20cells%2C%20I've%20also%20tried%20Removing%20the%20View%20Tab%20from%20the%20Ribbon%20but%20that%20only%20seems%20to%20apply%20to%20my%20workbook.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20Freeze%20the%20top%20two%20panes%2C%20then%20make%20it%20so%20others%20who%20access%20the%20shared%20file%20are%20UNABLE%20to%20Unfreeze%20the%20panes.%20The%20Protect%20Workbook%20(structure)%20does%20not%20seem%20to%20work.%20I'd%20appreciate%20the%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-757064%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-757246%22%20slang%3D%22en-US%22%3ERe%3A%20Prevent%20Unfreezing%20in%20a%20Shared%20Workbook%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-757246%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F377119%22%20target%3D%22_blank%22%3E%40Paneross%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20the%20only%20way%20is%20to%20use%20some%20VBA.%3C%2FP%3E%3CP%3EThe%20following%20code%20needs%20to%20be%20copied%20into%20the%20sheet%20module.%20Right%20click%20on%20sheet%20tab%2C%20and%20choose%20View%20Code.%20In%20the%20white%20pane%20that%20appears%20in%20the%20VB%20Editor%2C%20paste%20the%20code%2C%20then%20press%20Alt%2BF11%20to%20return%20to%20Excel.%3C%2FP%3E%3CP%3ERemember%20to%20save%20the%20file%20as%20a%20%2Cxlsm%20or%20.xlsb%20file%2C%20otherwise%20the%20code%20won't%20be%20saved.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBasically%20the%20code%20gets%20triggered%20whenever%20the%20user%20moves%20to%20another%20cell%20on%20the%20sheet.%20It%20looks%20to%20see%20if%20Freeze%20Panes%20is%20active%2C%20and%20if%20it%20isn't%20it%20sets%20it%20at%20the%20location%20you%20choose%20and%20returns%20the%20user%20to%20the%20cell%20they%20had%20selected.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPrivate%20Sub%20Worksheet_SelectionChange(ByVal%20Target%20As%20Range)%3CBR%20%2F%3EDim%20cellreturn%20As%20String%3CBR%20%2F%3Ecellreturn%20%3D%20ActiveCell.Address%3CBR%20%2F%3EApplication.EnableEvents%20%3D%20False%3CBR%20%2F%3EIf%20Not%20ActiveWindow.FreezePanes%20Then%3CBR%20%2F%3EActiveSheet.Range(%22A3%22).Select%20'%20change%20address%20to%20where%20you%20want%20panes%20frozen%3CBR%20%2F%3EActiveWindow.FreezePanes%20%3D%20True%3CBR%20%2F%3EActiveSheet.Range(cellreturn).Select%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3EApplication.EnableEvents%20%3D%20True%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-758941%22%20slang%3D%22en-US%22%3ERe%3A%20Prevent%20Unfreezing%20in%20a%20Shared%20Workbook%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-758941%22%20slang%3D%22en-US%22%3EThank%20you%20Roger%2C%20that%20worked%20perfectly!!!!!!!%3C%2FLINGO-BODY%3E
Paneross
New Contributor

Good Morning,

 

I have a Shared Workbook that I need to prevent others users from being able to Unfreeze Panes. I've already Protected the Sheet to and Locked specific cells, I've also tried Removing the View Tab from the Ribbon but that only seems to apply to my workbook.

 

I need to Freeze the top two panes, then make it so others who access the shared file are UNABLE to Unfreeze the panes. The Protect Workbook (structure) does not seem to work. I'd appreciate the help.

 

thanks

 

 

2 Replies
Solution

@Paneross 

I think the only way is to use some VBA.

The following code needs to be copied into the sheet module. Right click on sheet tab, and choose View Code. In the white pane that appears in the VB Editor, paste the code, then press Alt+F11 to return to Excel.

Remember to save the file as a ,xlsm or .xlsb file, otherwise the code won't be saved.

 

Basically the code gets triggered whenever the user moves to another cell on the sheet. It looks to see if Freeze Panes is active, and if it isn't it sets it at the location you choose and returns the user to the cell they had selected.

 

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cellreturn As String
cellreturn = ActiveCell.Address
Application.EnableEvents = False
If Not ActiveWindow.FreezePanes Then
ActiveSheet.Range("A3").Select ' change address to where you want panes frozen
ActiveWindow.FreezePanes = True
ActiveSheet.Range(cellreturn).Select
End If
Application.EnableEvents = True
End Sub

 

 

Thank you Roger, that worked perfectly!!!!!!!