Selects any range or Visual Basic procedure in any workbook, and activates that workbook if it's not already active.
Syntax
expression.Goto (Reference, Scroll)
expression A variable that represents an Application object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Reference | Optional | Variant | The destination. Can be a Range object, a string that contains a cell reference in R1C1-style notation, or a string that contains a Visual Basic procedure name. If this argument is omitted, the destination is the last range you used the Goto method to select. |
Scroll | Optional | Variant | True to scroll through the window so that the upper-left corner of the range appears in the upper-left corner of the window. False to not scroll through the window. The default is False. |
Remarks
This method differs from the Select method in the following ways:
- If you specify a range on a sheet that's not on top, Microsoft Excel will switch to that sheet before selecting. (If you use Select with a range on a sheet that's not on top, the range will be selected but the sheet won't be activated).
- This method has a Scroll argument that lets you scroll through the destination window.
- When you use the Goto method, the previous selection (before the Goto method runs) is added to the array of previous selections (for more information, see the PreviousSelections property). Use this feature to quickly jump between as many as four selections.
- The Select method has a Replace argument; the Goto method doesn't.
Example
This example selects cell A99 on Sheet1 and then scrolls through the worksheet to display the range.
Application.Goto Reference:=Worksheets("Sheet1").Range("A99"), scroll:=True