SpecialCells Method

Applies To

Range object.

Description

Returns a Range object that represents all the cells that match the specified type and value.

Syntax

expression.SpecialCells(Type, Value)

expression Required. An expression that returns a Range object.

Type Required Long. The cells to include. Can be one of the following XlCellType constants.

Constant

Description

xlCellTypeNotes

Cells containing notes

xlCellTypeConstants

Cells containing constants

xlCellTypeFormulas

Cells containing formulas

xlCellTypeBlanks

Empty cells

xlCellTypeLastCell

The last cell in the used range

xlCellTypeVisible

All visible cells


Value Optional Variant. If Type is either xlCellTypeConstants or xlCellTypeFormulas, this argument is used to determine which types of cells to include in the result. These values can be added together to return more than one type. The default is to select all constants or formulas, no matter what the type. Can be one of the following XlSpecialCellsValues constants: xlErrors, xlLogical, xlNumbers, xlTextValues, xlAllFormatConditions, or xlSameFormatConditions.

Example

This example selects the last cell in the used range of Sheet1.

Worksheets("Sheet1").Activate
ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Activate