excel中使用vba获取任意sheet最末尾一列空行
1、新建一个vba模块
2、输入以下函数Function getEmptyRow(sheetName As String, col As Long) As Long Dim rng As Range Set rng = ThisWorkbook.Sheets(sheetName).Cells(65536, col).End(xlUp) getEmptyRow = rng.Row + 1 Set rng = NothingEnd Function
3、调用此函数使用方法getEmptyRow("表名",列号) 即可返回空行数值(返回值为Long)使用举例有一个名为 invest的表(sheet),要获得第一列的末尾空行。在vba中写一个test()函数,调用上边函数来测试Function test() MsgBox getEmptyRow("invest", 1)End Function
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:46
阅读量:37
阅读量:53
阅读量:45
阅读量:74