Row Scanning – Return First Not Empty Cell Value (Left to Right)
Scans a row in an Excel.Worksheet from left to right and returns the value of the first non-empty cell.
The function begins scanning from the specified column in the given row and continues to the end of the worksheet columns.
VB
Public Function xlL2R_ReturnFirstNotEmptyCellValue(wsSheet As Excel.Worksheet,
ByRef RowNumber As Integer,
ByRef ColNumber As Integer) As String
For iColIndex As Integer = ColNumber To wsSheet.Columns.Count
If CStr(wsSheet.Cells(RowNumber, iColIndex).Value) <> "" Then
ColNumber = iColIndex
Return CStr(wsSheet.Cells(RowNumber, iColIndex).Value)
End If
Next
Return String.Empty
End Function