How to Lock Cells in Excel When Scrolling

If you want to restrict a user to work within a specific range of cells in Excel, you can lock the scroll area of your worksheet. This means that the user can only scroll within a certain range and cannot make any changes outside of that range. In this article, we’ll show you how to limit the scroll area in your worksheet with two methods: using the Developer tab and using a VBA code.

Method 1: Using the Developer Tab

1. Go to the Developer tab in Excel.

2. If you do not have the Developer tab, right-click on any of these tabs, click on customize the ribbon and in Excel options, dialog box. Make sure Developer is checked and now click, okay.

3. In the Controls section, click on Properties.

4. In the Sheet Properties window, locate the Scroll Area option and specify the area which in this case would be A1 2J25.

5. Manually type A1:J25, which is the range where you want the scroll area to be active.

6. Lock the scroll area to prevent the user from selecting and working with cells outside of the specified range.

Method 2: Using a VBA Code

1. Go to the Developer tab in Excel and click on Visual Basic.

2. In the VB editor, locate the ThisWorkbook option under Project Explorer and double-click on it to open the Workbook code window.

3. Select the Workbook_Open option from the drop-down menu.

4. Type Worksheet, then the name of the worksheet in double quotes, then ScrollArea is equal to within double quotes, A1 to J25.

5. Save the file as a macro-enabled file to ensure that the macro is not lost.

6. Close and reopen the file to see if the scroll area range has been applied.

If you have multiple sheets and want the same scroll area to be applied to all sheets, you can use a for loop in the VBA code. To do this, follow these steps:

1. Declare a new object as a worksheet (e.g. Dim WS as Worksheet).

2. Use the for each loop to specify each worksheet in the workbook.

3. Set the scroll area for each worksheet using the same range (e.g. A1:J25).

By using these methods, you can limit the user to a specific range and lock the scroll area for them. This is useful when sharing workbooks with colleagues or clients, as it prevents accidental changes to cells outside of the specified range.