Mega Code Archive

 
Categories / VisualBasic Script / Forms
 

Find the First Non-Zero-Length Cell in a Range

Sub FirstNonZeroLength(Rng As Range)     Dim myCell As Range     myCell = Range("A1:E3")     FirstNonZeroLength = 0#     For Each myCell In Rng         If Not IsNull(myCell) And myCell <> "" Then             Debug.Print myCell.Value             Exit Function         End If     Next myCell     Debug.Print myCell.Value End Function