SELECT macro

Equivalent to selecting cells or changing the active cell. There are three syntax forms of SELECT. Use syntax 1 to select a cell on a worksheet or macro sheet; use one of the other syntax forms to select worksheet or macro sheet objects or chart items.

Syntax 1   Selects cells

Syntax 2   Selects objects on worksheets

Syntax 3   Selects chart objects

Return to index

SELECT Syntax 1

Equivalent to selecting cells or changing the active cell. There are three syntax forms of SELECT. Use syntax 1 to select a cell on a worksheet or macro sheet; use one of the other syntax forms to select worksheet or macro sheet objects or chart items.

Syntax

SELECT(selection, active_cell)

Selection    is the cell or range of cells you want to select. Selection can be a reference to the active worksheet, such as !$A$1:$A$3 or !Sales, or an R1C1-style reference to a cell or range relative to the active cell in the current selection, such as "R[-1]C[-1]:R[1]C[1]". The reference must be in text form. If selection is omitted, the current selection is used.

Active_cell    is the cell in selection you want to make the active cell. Active_cell can be a reference to a single cell on the active worksheet, such as !$A$1, or an R1C1-style reference relative to the active cell, such as "R[-1]C[-1]". The reference must be in text form. If active_cell is omitted, SELECT makes the cell in the upper-left corner of selection the active cell.

Remarks

 

Tip   You can enter data in a cell without selecting the cell by using the reference arguments to the CUT, COPY, or FORMULA functions.

Examples

The following macro formula selects cells C3:E5 on the active worksheet and makes C5 the active cell:

SELECT(!$C$3:$E$5, !$C$5)

If the active cell is C3, the following macro formula selects cells E5:G7 and makes cell F6 the active cell in the selection:

SELECT("R[2]C[2]:R[4]C[4]", "R[1]C[1]")

You can also make multiple nonadjacent selections with SELECT. The following macro formula selects a number of nonadjacent ranges:

SELECT("R1C1, R3C2:R4C3, R8C4:R10C5")

The following sequence of macro formulas moves the active cell right, left, down, and up within the selection, just as TAB, SHIFT+TAB, ENTER, and SHIFT+ENTER do:

SELECT(, "RC[1]")

SELECT(, "RC[-1]")

SELECT(, "R[1]C")

SELECT(, "R[-1]C")

Use SELECT with the OFFSET function to select a new range a specified distance away from the current range. For example, the following macro formula selects a range that is the same size as the current range, one column over:

SELECT(OFFSET(SELECTION(), 0, 1))

Related Functions

ACTIVE.CELL   Returns the reference of the active cell

SELECT.SPECIAL   Selects a group of cells belonging to a category

SELECTION   Returns the reference of the selection

SELECT Syntax 2   Selects objects on worksheets

SELECT Syntax 3   Selects chart objects

Return to index

SELECT Syntax 2

Equivalent to selecting objects on a chart, worksheet, or macro sheet. There are three syntax forms of SELECT. Use syntax 2 to select an object on which to perform an action; use one of the other syntax forms to select cells on a worksheet or macro sheet or items on a chart.

Syntax

SELECT(object_id_text, replace)

Object_id_text    is text that identifies the object to select. Object_id_text can be the name of more than one object. To give the name of more than one object, use the following format:

SELECT("Oval 3, Arc 2, Line 4")

The last item in the object_id_text list will be the active object. The active object is important when moving and sizing a group of objects. A multiple selection of objects is moved and sized relative to the upper-left corner of the active object.

Replace    is a logical value that specifies whether previously selected objects are included in the selection. If replace is TRUE or omitted, Microsoft Excel only selects the objects specified by object_id_text; if FALSE, it includes any objects that were previously selected. For example, if a button is selected and a SELECT formula selects an arc and an oval, TRUE leaves only the arc and oval selected, and FALSE includes the button with the arc and oval.

Remarks

Objects can be identified by their object type and number as described in CREATE.OBJECT, or by the unique number that specifies the order of their creation. For example, if the third object you create is an oval, you could use either "oval 3" or "3" as object_id_text.

Examples

The following macro formulas each select a number of objects and specify Arc 2 as the active object:

SELECT("Oval 3, Arc 1, Line 4, Arc 2")

SELECT("3, 1, 4, 2")

Related Functions

FORMAT.MOVE   Moves the selected object

FORMAT.SIZE   Changes the size of the selected objects

GET.OBJECT   Returns information about an object

SELECTION   Returns the reference of the selection

SELECT Syntax 1   Selects cells

SELECT Syntax 3   Selects chart objects

Return to index

SELECT Syntax 3

Selects a chart object as specified by the selection code item_text. There are three syntax forms of SELECT. Use syntax 3 to select a chart item to which you want to apply formatting; use one of the other syntax forms to select cells or objects on a worksheet or macro sheet.

Syntax

SELECT(item_text, single_point)

Item_text    is a selection code from the following table which specifies which chart object to select.

To select

Item_text

Entire chart

"Chart"

Plot area

"Plot"

Legend

"Legend"

Primary chart value axis

"Axis 1"

Primary chart category axis

"Axis 2"

Secondary chart value axis or 3-D series axis

"Axis 3"

Secondary chart category axis

"Axis 4"

Chart title

"Title"

Label for the primary chart value axis

"Text Axis 1"

Label for the primary chart category axis

"Text Axis 2"

Label for the primary chart series axis

"Text Axis 3"

nth floating text item

"Text n"

nth arrow

"Arrow n"

Major gridlines of value axis

"Gridline 1"

Minor gridlines of value axis

"Gridline 2"

Major gridlines of category axis

"Gridline 3"

Minor gridlines of category axis

"Gridline 4"

Major gridlines of series axis

"Gridline 5"

Minor gridlines of series axis

"Gridline 6"

Primary chart droplines

"Dropline 1"

Secondary chart droplines

"Dropline 2"

Primary chart hi-lo lines

"Hiloline 1"

Secondary chart hi-lo lines

"Hiloline 2"

Primary chart up bar

"UpBar1"

Secondary chart up bar

"UpBar2"

Primary chart down bar

"DownBar1"

Secondary chart down bar

"DownBar2"

Primary chart series line

"Seriesline1"

Secondary chart series line

"Seriesline2"

Entire series

"Sn"

Data associated with point m in series n if single_point is TRUE

"SnPm"

Text attached to point m of series n

"Text SnPm"

Series title text of series n of an area chart

"Text Sn"

Base of a 3-D chart

"Floor"

Back of a 3-D chart

"Walls"

Corners of a 3-D chart

"Corners"

Trend line

"SnTm"

Error bars

"SnEm"

Legend Marker

"Legend Marker n"

Legend Entry

"Legend Entry n"

For trend lines and error bars, the value m can be X or Y, depending on which point you want to select. If m is blank, selects both.

Single_point    is a logical value that determines whether to select a single point. Single_point is available only when item_text is "SnPm".

 

Examples

SELECT("Chart") selects the entire chart.

SELECT("Dropline 2") selects the droplines of an overlay chart.

SELECT("S1P3", TRUE) selects the third point in the first series.

SELECT("Text S1") selects the series title text of the first series in an area chart.

Related Functions

SELECTION   Returns the reference of the selection

SELECT Syntax 1   Selects cells

SELECT Syntax 2   Selects objects on worksheets

Return to index