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