How do I restrict the visible area of a spreadsheet? I have a spreadsheet and I don;t want the user to be able to scroll across into the other columns or down to the other rows? Can I do this?
You can do this with a macro - if you change its name to Autpen it will run automatically when the workbook is opened. It will only prevent scrolling, not viewing.
Code:
Sub RestrictScrollArea()
With ThisWorkbook.Worksheets("Sheet1")
.ScrollArea = "A1:D4"
End With
End Sub
Private Sub Workbook_Open()
Sheets("Sheet1").ScrollArea = ("A1:H10")
End Sub
The above code will restrict the user to the range A1:H10. Unfortunately this setting isn't saved with the file so this code would need running every time the file is opened - hence the Workbook_Open routine. It needs copying into the ThisWorkbook module of the VBE.
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.