Returns the last cell that contains data in a particular row.


* For instructions on how to add a function to a workbook refer to the page under Inserting Functions
* The equivalent JavaScript function is LASTINROW

Function LASTINROW(rngInput As Range) As Variant 
    Dim WorkRange As Range
    Dim i As Integer, CellCount As Integer
    Set WorkRange = rngInput.Rows(1).EntireRow
    Set WorkRange = Intersect(WorkRange.Parent.UsedRange, WorkRange)
    CellCount = WorkRange.Count
    For i = CellCount To 1 Step -1
        If Not IsEmpty(WorkRange(i)) Then
            LASTINROW = WorkRange(i).Value
            Exit Function
        End If
    Next i
End Function

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext