Prevent users unfreezing panes

SaraWitch

Active Member
Joined
Sep 29, 2015
Messages
322
Office Version
  1. 365
Platform
  1. Windows
Hello peeps.

Is there a way to prevent users from unfreezing panes in a shared workbook? It used to be done by selecting 'Windows' in the Protect Workbook function, but this feature has been deprecated. I also tried a vba that I found elsewhere, but this does not work either.

VBA Code:
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

If this can be done, any help would be appreciated :)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
That VBA should work, but has the following requirements for it to work automatically.
1. It MUST be placed in the Sheet module in VBA of the sheet you want to apply it to. If you place it in a general or workbook module, it will NOT work
2. You CANNOT change the name of this procedure - it MUST be named "Private Sub Worksheet_SelectionChange(ByVal Target As Range"
3. VBA MUST be enabled in your workbook in order for it to work

Regarding item #1, the easiest way to ensure you put it in the proper place is to go to the sheet you want to apply it to, right-click on sheet tab name at the bottom of the screen, select "View Code", and paste the VBA code in the VBA module that pops up.
 
Upvote 1
Thank you, @Joe4. All that was true. But... ...you know what I was doing?!? Scrolling down and across without moving into another cell!!!! 🤦‍♀️ Doh! It does work, and works perfectly - thank you again for your time :)
 
Upvote 0
You are welcome.
Glad you got it all worked out!
 
Upvote 0

Forum statistics

Threads
1,215,156
Messages
6,123,339
Members
449,098
Latest member
thnirmitha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top