SpecialCells Method [Excel 2003 VBA Language Reference]

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

expression.SpecialCells(Type, Value)

expression Required. An expression that returns one of the objects in the Applies To list.

XlCellType

XlCellType constants Value
xlCellTypeAllFormatConditions. Cells of any format -4172
xlCellTypeAllValidation. Cells having validation criteria -4174
xlCellTypeBlanks. Empty cells 4
xlCellTypeComments. Cells containing notes -4144
xlCellTypeConstants. Cells containing constants 2
xlCellTypeFormulas. Cells containing formulas -4123
xlCellTypeLastCell. The last cell in the used range 11
xlCellTypeSameFormatConditions. Cells having the same format -4173
xlCellTypeSameValidation. Cells having the same validation criteria -4175
xlCellTypeVisible. All visible cells 12

XlSpecialCellsValue

XlSpecialCellsValue constants Value
xlErrors 16
xlLogical 4
xlNumbers 1
xlTextValues 2

Example

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

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

Applies to | Range Collection