The fastest way to scroll to a specific cell in Excel VBA is to use the Application.Goto method, for example: Application.Goto Worksheets("Sheet1").Range("A100"). This selects the cell and scrolls the window so it is visible. For more control, you can use the Window.ScrollRow and Window.ScrollColumn properties, which move the view without changing the selection.
Why Scroll Programmatically?
In a large worksheet, jumping to a cell manually means endless scrolling or typing a cell address into the Name Box. VBA gives you precise, repeatable navigation. You might need to:
- Show the result of a calculation to the user.
- Move to the last used row in a data set.
- Return to a specific input area after running a macro.
- Cycle through a list of flagged cells.
Scrolling with code is also faster than using Range.Select alone, because Select changes the selection but does not always bring the cell into view, especially if the cell is off-screen.
Using Application.Goto
The Application.Goto method is the simplest way to scroll to a cell. It selects the range and scrolls the active window to show it. The syntax is:
Application.Goto Reference:=Worksheets("Sheet1").Range("C50")
You can also use a named range or a cell reference from another workbook. If you want to scroll to a cell without selecting it, you can set the Scroll argument to True (the default) or False to only select without scrolling. For example, to select a cell but not scroll:
Application.Goto Reference:=Range("A1"), Scroll:=False
Note that Application.Goto works with any range, not just a single cell. It will scroll to show the entire range if possible.
Using Window.ScrollRow and ScrollColumn
If you want to scroll the window to a specific row or column without changing the active cell, use the ScrollRow and ScrollColumn properties of the Window object. For example, to scroll to row 500 while keeping the selection where it is:
ActiveWindow.ScrollRow = 500
To scroll to a specific column (e.g., column 10, which is “J”):
ActiveWindow.ScrollColumn = 10
You can set both together to position the view at a specific cell. Note that these properties set the top-left visible cell, not the center. If you want the cell centered, you may need to calculate the offset based on the visible rows and columns.
Scrolling to the Last Used Cell
A common task is to scroll to the last used cell in a column or row. You can find the last used row with the End property, similar to pressing Ctrl+Down. For example, to scroll to the last non-empty cell in column A:
Dim lastRow As Long
lastRow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Application.Goto Worksheets("Sheet1").Cells(lastRow, "A")
This works for columns as well. To scroll to the last used cell in the entire worksheet, you can use UsedRange:
Application.Goto Worksheets("Sheet1").UsedRange.SpecialCells(xlCellTypeLastCell)
Remember that SpecialCells(xlCellTypeLastCell) returns the last cell that has ever been formatted or edited, so it might be beyond your actual data if you have leftover formatting.
Common Problems and Solutions
Here are a few issues you might encounter when scrolling with VBA:
- Cell not visible after Select: If you use
Range("A100").Select, the cell may not be visible if the window is frozen or if the cell is far away. UseApplication.Gotoinstead. - Frozen panes: If you have frozen rows or columns,
Application.Gotowill still scroll to the cell, but the frozen area stays fixed. To scroll to a cell that is under the frozen area, you may need to temporarily unfreeze panes. - ScrollRow/ScrollColumn not updating: These properties only work on the active window. If you have multiple windows, make sure you reference the correct one.
- Scroll position not resetting: If you scroll to a cell and then want to go back to the top, set
ActiveWindow.ScrollRow = 1andActiveWindow.ScrollColumn = 1.
Comparing Goto vs. ScrollRow
Both methods have their place. Application.Goto is easier and more intuitive, but it changes the selection. ScrollRow and ScrollColumn are more flexible because they only move the view. Here’s a quick comparison:
- Application.Goto – selects the cell, scrolls to it, and works with any range. Good for most cases.
- ScrollRow/ScrollColumn – does not change selection, gives precise control over the top-left visible cell. Good for keeping the user’s place while showing context.
In practice, you might use Application.Goto for simple navigation and ScrollRow for more complex scenarios like scrolling to a row while keeping a header visible.
Alternatives and Best Practices
If you need to scroll to a cell as part of a larger macro, consider these tips:
- Use
Application.ScreenUpdating = Falseat the start of your macro to speed up execution, then set it back toTrueat the end. This prevents the screen from flickering during multiple scroll operations. - If you are using
Application.Gotowith a range that is not on the active sheet, Excel will activate that sheet. To avoid changing the active sheet, you can useActiveWindow.ScrollRowandScrollColumninstead. - Always save a copy of your workbook before running a macro that scrolls or selects cells, because macros cannot be undone with Ctrl+Z.
Frequently Asked Questions
How do I scroll to a cell in VBA without selecting it?
Use ActiveWindow.ScrollRow and ActiveWindow.ScrollColumn to move the view without changing the selection. For example, to scroll to cell E10, set ActiveWindow.ScrollRow = 10 and ActiveWindow.ScrollColumn = 5.
Can I scroll to a cell in a different worksheet?
Yes, but you need to activate that worksheet first, or use Application.Goto which will activate the sheet. For example, Application.Goto Worksheets("Data").Range("B2") will switch to the “Data” sheet and scroll to B2.
How do I scroll to a cell using a keyboard shortcut in VBA?
You can assign a macro to a keyboard shortcut via the Macro dialog (Alt+F8, Options). In the macro, use Application.Goto to the desired cell. The shortcut will run the macro and scroll to the cell.
Why does Application.Goto not scroll to the cell?
If the cell is already visible on screen, Application.Goto will not scroll. Also, if the worksheet is protected or the window is minimized, it may not scroll. Ensure the window is active and the cell is not hidden by filters.
How do I scroll to a cell in Excel for Mac?
The VBA code is the same. The only difference is that keyboard shortcuts use Cmd instead of Ctrl, but the code itself works identically.
Related
- SQL Server COUNT DISTINCT: Syntax, Examples, and Pitfalls
- How to Select a Cell in Excel: Quick Steps
- What Are Shortcut Keys? Full Guide
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA AutoFilter Multiple Fields: Examples and TipsTo filter multiple Excel fields with VBA, call AutoFilter on the same range once for each column, using…
- VBA Code to Send an Email With an AttachmentTo send an email with an attachment from Excel VBA on Windows, create an Outlook mail item, add…
- Concat in Excel VBA: Join Text with the & OperatorTo concatenate text in Excel VBA, use the ampersand operator, &, to join values, such as fullName =…
- Excel Analysis ToolPak VBA: Setup, Limits, and UseYes—Excel can work with the Analysis ToolPak and VBA, but the add-in is not a universal VBA interface…
- VBA Range to String Array: 2 Reliable MethodsThe most direct way to convert a VBA range to a string array is to read the range’s…
- VBA For Loop Syntax: Examples and Common VariationsIn VBA, a For...Next loop repeats code for a counter that moves from a starting value to an…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.