By using vba.booksticle.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes
Something went wrong.
   
   inc_db_routines - Error during logging -2147217833 [Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated.
   strSQL = Insert into Log (ev_date,ev_complete,ev_elapsed,ip_addr,url_val,referer,action_val,action_comment) values ('6/29/2025 1:51:18 AM','6/29/2025 1:51:20 AM',1.469727,'216.73.216.232','https://vba.booksticle.com/showlist2.asp?parent=127303','','dbr2653 -2147467259 [Microsoft][ODBC SQL Server Driver][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.Findlastrow - udf - finds the last row in a column -2147467259 ','
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)')
Something went wrong.
Something went wrong.
   dbr2598: 0

948 Steps to 6 Figures by Learning Excel-VBA and Other Skills



Step -1 - Findlastrow - udf - finds the last row in a column


Highly used function to find the last row based on the passed column



Function FindLastRow(c As Long) As Long
'Version: 1.001
'Purpose: This routine will find the last row in the spread sheet for the passed column
' c is the column to use to find the last row
' ignore's hidden rows
'1.001 didn't work if formula set cell to a blank

Dim prevRow As Long

'Go to the end
On Error Resume Next
Cells(Cells.Rows.Count, c).Select '
If Err <> 0 Then
    FindLastRow = 0
    Exit Function
End If

Selection.End(xlUp).Select
prevRow = 0
Do While Trim(ActiveCell.Text) = "" And ActiveCell.Row <> 1
'    Selection.End(xlUp).Select
    ActiveCell.Offset(-1, 0).Select
    
    
    If ActiveCell.Row = prevRow Then
        FindLastRow = ActiveCell.Row
        Exit Function
    Else
        prevRow = ActiveCell.Row
    End If
    
Loop

FindLastRow = ActiveCell.Row


End Function


   Table of Contents | Send us your feedback | © 2025 All Rights Reserved | Edit