Activate Method

Applies To

Chart Object, ChartObject Object, DialogSheet Object, MenuBar Object, Module Object, OLEObject Object, Pane Object, Range Object, Window Object, Workbook Object, Worksheet Object.

Description

Activates the object, as shown in the following table.

Object

Description

Chart, ChartObject

Makes this chart the active chart.

DialogSheet, Module, Worksheet

Makes this sheet the active sheet. Equivalent to clicking the tab.

MenuBar

Activates the menu bar. There are certain restrictions on which menu bars you can activate at certain times. See the Remarks section for details.

OLEObject

Activates the object.

Pane

Activates the pane. If the pane is not in the active window, the window that the pane belongs to will also be activated. You cannot activate a frozen pane.

Range

Activates a single cell, which must be inside the current selection. To select a range of cells, use the Select method.

Window

Brings the window to the front of the z-order. This will not run any Auto_Activate or Auto_Deactivate macros that might be attached to the workbook (use the RunAutoMacros method to run those macros).

Workbook

Activates the first window associated with the workbook. This will not run any Auto_Activate or Auto_Deactivate macros that might be attached to the workbook (use the RunAutoMacros method to run those macros).


Syntax

object.Activateobject

Required. The object to activate.

Remarks

When you activate a built-in menu bar, you can display only a menu bar appropriate for the object. For example, if you try to display a chart menu bar for a worksheet or macro sheet, this method returns an error and interrupts the current macro.

Activating a custom menu bar disables automatic menu bar switching when different types of documents are selected. For example, if a custom menu bar is displayed and you switch to a chart, the two chart menus are not displayed (they would be if you were using the built-in menu bars). Automatic menu bar switching is reenabled when a built-in menu bar is displayed.

See Also

Select Method.

Example

This example activates Sheet1 in the workbook BOOK1.XLS.


Workbooks("BOOK1.XLS").Worksheets("Sheet1").Activate

This example selects cells A1:C3 on Sheet1 and then makes cell B2 the active cell.


Worksheets("Sheet1").Activate
Range("A1:C3").Select
Range("B2").Activate

This example activates the workbook BOOK4.XLS. If BOOK4.XLS has multiple windows, the example activates the first window, BOOK4.XLS:1.


Workbooks("BOOK4.XLS").Activate