The following VBA code can help you to limit the scroll area for a particular worksheet.
VBA code
Excel’s ScrollArea property allows you to set the scroll area for a particular worksheet. For instance, this statement sets the scroll area on Sheet1 so the user cannot activate any cells outside of A1:G10.
Sub LimitScrollArea()
Sheets("Sheet1").ScrollArea = "A1:G10"
End Sub
If for some reason you need to clear the scroll area limits, you can remove the restriction with this statement:
ActiveSheet.ScrollArea = ""
How to Use This Macro
To use this macro, you can copy and paste it into a standard module:
- Activate the Visual Basic Editor by pressing ALT F11.
- Right-click the project/workbook name in the Project window.
- Choose Insert -> Module.
- Type or paste the code in the newly created module.
This worked for me for desktop excel file but not for the online excel version.