Otherwise the following error will occur: Compile error: Sub or Function not defined.

Required functions are listed below. You can get to each function's source code by clicking its name:

When adding the functions above to your VBA project, make sure you haven't done it before. If there are two different public functions with the same name in a single VBA project, the following compilation error is thrown: Compile error: Ambiguous name detected: function_name.

'**********************************************************************************************************
' Name: firstNonEmptyRow
' Author: mielk | 2012-04-05
'
' Comment: Function to return the index number of the first non-empty row in the given
' Excel worksheet.
'
' Parameters:
' wks An Excel worksheet for which the first non-empty row is to be found.
' startRow Optional parameter of Long type.
' * It allows to limit the range being searched. If this argument is specified macro
' starts searching from this row instead of the first row in the given worksheet
' and ignores all the rows above it.
' * If this argument is equal to 0, macro works as if it is not specified at all and
' searching starts from the first row of this file.
' startCol Optional parameter of Long type.
' * It allows to limit the range being searched. If this argument is specified macro
' starts searching from this column instead of the first column in the given
' worksheet.
' * If this argument is equal to 0, macro works as if it is not specified at all and
' searching starts from the first column of this file.
' endRow Optional parameter of Long type.
' * It allows to limit the range being searched. If this argument is specified macro
' searches only to this row instead of to the end of the file and ignores all
' the cells below this row.
' * If this argument is equal to 0, macro works as if it is not specified at all
' and searches through all the rows to the end of this file.
' endCol Optional parameter of Long type.
' * It allows to limit the range being searched. If this argument is specified macro
' analyzes range only to this column instead of to the end of this worksheet.
' * If this argument is equal to 0, macro works as if it is not specified at all
' and searches all the columns to the end of this file.
' ignoreHiddenCells Optional parameter of Boolean type.
' * It determines if the function should ignore hidden cells when searching.
' * By default, this parameter is set to False. If it is omitted, the function
' includes are cells, no matter if they are hidden or not.
'
' Returns:
' Long The index number of the first non-empty row in the given Excel worksheet.
' If there is no non-empty rows in the given worksheet 0 is returned.
'
'
' Exceptions:
' IllegalSheetException Thrown if the worksheet given to the function as the [wks] parameter
' is damaged or has been closed and it is not possible to refer to its
' rows or columns.
'
'
' --- Changes log -----------------------------------------------------------------------------------------
' 2013-04-23 mielk Function created.
'**********************************************************************************************************Public Function firstNonEmptyRow(wks As Excel.Worksheet, _Optional startRow As Long, Optional startCol As Long, _Optional endRow As Long, Optional endCol As Long, _Optional ignoreHiddenCells As Boolean = False) As LongConst METHOD_NAME As String = "firstNonEmptyRow" '------------------------------------------------------------------------------------------------------Dim lngRow As LongDim lngRowStart As LongDim lngRowEnd As LongDim lngNonBlanks As LongDim lngColStart As LongDim lngColEnd As LongDim rng As Excel.Range '------------------------------------------------------------------------------------------------------

'Checks if the given worksheet is valid and can be referred to. -------------------------------------|
'If not, the code jumps to the label IllegalSheetException, where you can define your own '|
'error handling rules for this exception. '|If Not isSheetValid(wks) Then GoTo IllegalSheetException '|
'----------------------------------------------------------------------------------------------------|

'----------------------------------------------------------------------------------------------------------IllegalSheetException: '(...)
'Put your own error handling here for a case if the given worksheet has been closed or removed.