Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Base 1
Option Explicit
Function GetLastEntry(Col_of_Cells As Range) As Variant
'
' Input is a column of cells.
' Output is the last USED cell of the column.
'
Dim I As Long, NR As Long, NC As Long
Dim Ans As Variant
'
NR = Col_of_Cells.Rows.Count
NC = Col_of_Cells.Columns.Count
If NR < 1 Or NC <> 1 Then
MsgBox "Input must be a single-column range.", , "Function GetLastEntry"
GetLastEntry = CVErr(xlErrRef)
Exit Function
End If
'
' Search, from bottom up, for the first non-empty cell.
' Note that the IsNull function does not do the job here.
'
For I = NR To 1 Step -1
If Not IsEmpty(Col_of_Cells(I)) Then
Ans = Col_of_Cells(I)
GoTo FoundIt
End If
Next I
Ans = CVErr(xlErrNA)
'
FoundIt:
GetLastEntry = Ans
End Function