excel中使用vba获取任意sheet最末尾一列空行

2025-05-08 19:59:53

1、新建一个vba模块

excel中使用vba获取任意sheet最末尾一列空行

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

excel中使用vba获取任意sheet最末尾一列空行

3、调用此函数使用方法getEmptyRow("表名",列号) 即可返回空行数值(返回值为Long)使用举例有一个名为 invest的表(sheet),要获得第一列的末尾空行。在vba中写一个test()函数,调用上边函数来测试Function test() MsgBox getEmptyRow("invest", 1)End Function

excel中使用vba获取任意sheet最末尾一列空行
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢