How can I find last row that contains data in a specific column?

后端 未结 13 1586
南笙
南笙 2020-11-22 03:44

How can I find the last row that contains data in a specific column and on a specific sheet?

13条回答
  •  醉酒成梦
    2020-11-22 04:26

    Function LastRow(rng As Range) As Long
        Dim iRowN As Long
        Dim iRowI As Long
        Dim iColN As Integer
        Dim iColI As Integer
        iRowN = 0
        iColN = rng.Columns.count
        For iColI = 1 To iColN
            iRowI = rng.Columns(iColI).Offset(65536 - rng.Row, 0).End(xlUp).Row
            If iRowI > iRowN Then iRowN = iRowI
        Next
        LastRow = iRowN
    End Function 
    

提交回复
热议问题