Limit Scroll Area Use Excel VBA

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:

  1. Activate the Visual Basic Editor by pressing ALT F11.
  2. Right-click the project/workbook name in the Project window.
  3. Choose Insert -> Module.
    Insert Module
  4. Type or paste the code in the newly created module.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *