Column Scanning – Return First Not Empty Cell Value (Top to Bottom)
Scans a column in an Excel.Worksheet from top to bottom and returns the value of the first non-empty cell.
The function scans from the top of the specified column and stops at the first cell that is not Nothing.
VB
Public Function xlT2B_ReturnFirstNotEmptyCellValue(wsSheet As Excel.Worksheet,
ByRef RowNumber As Integer,
ByRef ColNumber As Integer) As String
For iRowIndex As Integer = 1 To wsSheet.Rows.Count
If Not wsSheet.Cells(iRowIndex, ColNumber).Value Is Nothing Then
RowNumber = iRowIndex
Return CStr(wsSheet.Cells(RowNumber, ColNumber).Value)
End If
Next
Return String.Empty
End Function