In the following dataset which we will use to illustrate our methods, we have some people’s IDs, Names, and Email addresses. Let’s lock the cells without data so that the Excel sheet will not scroll.
Method 1 – Using Developer Property to Stop Excel from Scrolling to Infinity
This method is a temporary process; if you close your workbook and open it again, it won’t work.
Steps:
- Go to the Developer tab >> select Properties.
- Enter the range that you want to be enabled for scrolling in the Properties box. Here, $A$1:$E$14.
- Close the Properties box.
Your Excel sheet now will not permit scrolling outside this range.
Method 2 – Using VBA to Stop an Excel Sheet from Scrolling to Infinity
Applying this method will also allow formatting any cells you want.
- Go to the Developer tab >> select Visual Basic.
- Select Insert >> Module.
- A VBA Module will open. Enter the following code in that module:
Sub StopScrollingAndFormat()
Sheets("vba").Select
ActiveSheet.ScrollArea = ""
Range("C7").Select
Selection.Font.Bold = True
ActiveSheet.ScrollArea = "$A$1:$E$15"
End Sub
Code Explanation
- We name our Sub Procedure as StopScrollingAndFormat.
- We select the sheet named vba.
- We set the Scroll Area of that sheet to Infinity.
- Cell C7 is selected via VBA Range method and its font is formatted to Bold.
- We set the range $A$1:E$15$ as the Scroll Area of the Active Sheet.
- Go back to your sheet and Run the Macro.
The name in cell C7 becomes Bold, and you will not be able to scroll down your Excel sheet.
The operation resets after closing your workbook, meaning when you open your Excel file, it won’t work.
Method 3 – Using VBA to Stop Scrolling from Infinity for a Range of Cells
This method provides a permanent solution to stop scrolling. It will retain the scroll lock even if you close and open your Excel workbook.
Steps:
- Follow Method 2 to open the VBA Editor.
- Open the workbook sheet from the VBAProject window and enter the following code in it:
Private Sub Worksheet_Activate()
Me.ScrollArea = "A1:E15"
End Sub
Here, we activate worksheet for Private Sub Procedure and set the desired scrolling area. In this case, we set the range A1:E15 for scrolling, making it impossible to select any cell outside this range and scroll down.
- Press CTRL+S to save the file and go back to your sheet.
In this case, the name of the sheet is a workbook.
Method 4 – Using VBA to Stop Scrolling to Infinity for a Used Range
You can also define a used range to lock and thus stop scrolling to infinity.
Steps:
- Follow Method 2 to open the VBA Editor.
- Open the ‘used range’ sheet from the VBAProject window and enter the following code in it:
Private Sub Worksheet_Activate()
Me.ScrollArea = Range(Me.UsedRange, Me.UsedRange(13, 4)).Address
End Sub
Here, we activate worksheet for Private Sub Procedure and set the desired scrolling area by the UsedRange property of VBA. In this case, we set the UsedRange Address to (13, 4) which means only 13 rows and 4 columns from where the data starts will be available to scroll or edit.
- Press CTRL+S to save the file and go back to your sheet.
In this case, the name of the sheet is workbook. You won’t be able to select any of the cells outside the range set by UsedRange or scroll.
Method 5 – Hiding Rows or Columns to Stop Excel from Scrolling to Infinity
Steps:
- Select the empty row after your dataset. Here, that’s the 13th row, but you can choose other rows if you want.
- Press CTRL+SHIFT+Down Arrow key, which will select all the remaining empty rows in that sheet.
- Right-click on any of the selected cells and select Hide.
All the empty rows will not be visible anymore.
- Select the column after which you want to lock scrolling. Here, that’s column F.
- Press CTRL+SHIFT+Left Arrow to select all the empty columns after the F column.
- Right-click on any of the selected cells and select Hide.
All the empty columns are now not visible, and you cannot scroll down to infinity.
Read More: Horizontal Scroll Not Working in Excel
Method 6 – Stop Scrolling to Infinity by Turning Off Horizontal and Vertical Scroll Bars
Steps:
- Go to the File tab.
- Select Options.
- In the Options window, go to Advanced >> Display options for this workbook.
- Uncheck both ‘Show horizontal scroll bar’ and ‘Show vertical scroll bar’.
- Click OK.
The Horizontal and Vertical Scroll Bars become hidden.
You won’t be able to scroll with your mouse to the right but you can still scroll down. So this method stops horizontal scrolling to infinity.
Read More: [Fixed!] Up and Down Arrows Not Working in Excel
Method 7 – Delete Invisible Cells to Stop Scrolling to Infinity
If you have data in the lower cells that cannot be seen, you can delete it to reset the scroll bar to its original position.
Steps:
Suppose you have data in cell C1048562.
- Select the 13th row and press CTRL+SHIFT+Down Arrow.
This operation will select all the rows below the 12th row.
- Press CTRL + – (minus) to delete all the empty cells along with the data in C1048562.
This resets the position of the vertical scroll bar, but it still remains in infinity view.
- Press CTRL+S to save the file.
The scroll bar now fits to the sheet, meaning it is no longer in infinity mode.
Download Practice Workbook
Related Articles
- [Fixed!]: Arrow Keys Not Moving Between Cells in Excel
- [Solved!] Vertical Scroll Not Working in Excel
- How to Stop Excel from Jumping Cells When Scrolling
- How to Stop Arrow Keys from Scrolling in Excel
- Excel Not Scrolling with Arrow Keys
<< Go Back to Scrolling in Excel | Navigation in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!