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.

Leave a comment

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

Format your code: <pre><code class="language-vba">place your code here</code></pre>

7 comments
  1. TE
    TJ Ev

    This worked for me for desktop excel file but not for the online excel version.

More comments