Skip to sidebar Skip to content
Ipercube Technical
Jack of all trades, master of none
Date: Time: - Stardate:
Welcome, Log in by clicking  Here!
SS64
MDN
Stack
Code
GitHub
Wiki
Convert
V Studio
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions
Ipercube Technical
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions

Utility – Get First Blank Row

Scans a range of columns row by row in an Excel.Worksheet and returns the index of the first blank row within that range.

The function determines the last used row in the starting column and scans each row from StartRow up to that point, checking whether all specified columns in the row are empty.

VB
    Function xlFirstBlankRow(wsSheet As Excel.Worksheet, 
                             StartRow As Integer, 
                             StartColumn As Integer, 
                             EndColumn As Integer) As Integer

        Dim iRow As Integer

        Dim rowCount As Integer
        Dim iRowIndex As Integer, iColIndex As Integer

        Dim currentRowValue As String

        rowCount = wsSheet.Cells(wsSheet.Rows.Count, StartColumn).End(xlUp).Row

        'Check il all the cell fron StartCol to EndCol are empty
        For iRowIndex = StartRow To rowCount
            Dim bIsEmpty As Boolean : bIsEmpty = True
            For iColIndex = StartColumn To EndColumn
                currentRowValue = CStr(wsSheet.Cells(iRowIndex, iColIndex).Value)

                bIsEmpty = String.IsNullOrEmpty(currentRowValue) And bIsEmpty
            Next

            If bIsEmpty Then
                iRow = iRowIndex
                Exit For
            End If
        Next

        Return iRow

    End Function

Posted by ipercube


© 2026 Ipercube Design