`
xieyunbiao
  • 浏览: 36947 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

获取已使用单元格的结尾位置(包括格式化的空单元格)

 
阅读更多

Dim lLastRow As Long

Dim lLastColumn As Long

With Range("A1").SpecialCells(xlCellTypeLastCell)

        lLastRow =.Row

        lLastColumn =.Column

End With

SpecialCells 方法

返回一个 Range 对象,该对象代表与指定类型及值相匹配的所有单元格。Range 对象。

 

expression.SpecialCells(Type, Value)

 

expression   必需。该表达式返回“应用于”列表中的一个对象。

 

Type   XlCellType 类型,必需。要包含的单元格。

 

XlCellType 可为以下 XlCellType 常量之一。 

xlCellTypeAllFormatConditions 任意格式单元格 

xlCellTypeAllValidation 含有验证条件的单元格 

xlCellTypeBlanks 空单元格 

xlCellTypeComments 含有注释的单元格 

xlCellTypeConstants 含有常量的单元格 

xlCellTypeFormulas 含有公式的单元格 

xlCellTypeLastCell 使用区域中最后的单元格 

xlCellTypeSameFormatConditions 含有相同格式的单元格 

xlCellTypeSameValidation 含有相同验证条件的单元格 

xlCellTypeVisible 所有可见单元格 

 

Value   Variant 类型,可选。如果 Type 为 xlCellTypeConstants 或 xlCellTypeFormulas 之一,此参数可用于确定结果中应包含哪几类单元格。将某几个值相加可使此方法返回多种类型的单元格。默认情况下,将选定所有常量或公式,对其类型不加区别。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics