XmlMappedRange.SpecialCells(XlCellType, Object) 方法

定义

获取一个 Range,它表示匹配指定类型和值的所有单元格。

public Microsoft.Office.Interop.Excel.Range SpecialCells (Microsoft.Office.Interop.Excel.XlCellType Type, object Value);
abstract member SpecialCells : Microsoft.Office.Interop.Excel.XlCellType * obj -> Microsoft.Office.Interop.Excel.Range
Public Function SpecialCells (Type As XlCellType, Optional Value As Object) As Range

参数

Type
XlCellType

要包含的单元格。可以是以下 XlCellType 值之一: xlCellTypeAllFormatConditions。 任何格式的单元格。 xlCellTypeAllValidation. 具有验证条件的单元格。 xlCellTypeBlanks. 空单元格。 xlCellTypeComments. 包含说明的单元格。 xlCellTypeConstants. 包含常量的单元格。 xlCellTypeFormulas. 包含公式的单元格。 xlCellTypeLastCell. 所使用范围中的最后一个单元格。 xlCellTypeSameFormatConditions. 具有相同格式的单元格。 xlCellTypeSameValidation. 具有相同验证条件的单元格。 xlCellTypeVisible. 所有可见的单元格。

Value
Object

如果 TypexlCellTypeConstantsxlCellTypeFormulas,则此参数用于确定要包含在结果中的单元格类型。 这些值可以一起添加以返回多种类型。 默认情况下,无论是何种类型,都选择所有的常数或公式。 可以是以下 XlSpecialCellsValue 值之一: xlErrorsxlLogicalxlNumbersxlTextValues

返回

一个 Range,表示匹配指定类型和值的所有单元格。

示例

下面的代码示例使用 SpecialCells 方法获取并选择包含 中的 XmlMappedRange注释的单元格区域。 此代码示例假定当前工作表包含名为 XmlMappedRangeCustomerLastNameCell

private void SelectRangeWithComments()
{
    this.CustomerLastNameCell.AddComment("This cell contains " +
        "a last name.");

    Excel.Range range1 = this.CustomerLastNameCell.SpecialCells(
        Excel.XlCellType.xlCellTypeComments);
    range1.Select();
}
Private Sub SelectRangeWithComments()
    Me.CustomerLastNameCell.AddComment(("This cell contains " & _
        "a last name."))

    Dim range1 As Excel.Range = Me.CustomerLastNameCell.SpecialCells( _
        Excel.XlCellType.xlCellTypeComments)
    range1.Select()
End Sub

注解

可选参数

有关可选参数的信息,请参阅 Office 解决方案中的可选参数

适用于