$show=home$hide=mobile-page

Excel Function to find Last Row in Column

Excel custom function to find last row in the specified column. Function can return last row number, last row content and last row address.

Excel custom function to find last row in the specified column. Function can return last row number, last row content and last row address
A custom Microsoft Excel function to find last row of a specified column.

Function can return the last row number, last row content value and address of the last row.
Function Name LastRowInColumn(col_no, sheet_name, Optional dtype = 0)
Function Description Excel Function to find Last Row in Column
Data Parameters col_no:- Specify the column number
sheet_name:- Specify the name of the sheet
dtype:- 0 to return row number, 1 to return last row content, 2 to return last row address

'------------------------------------------------------------------------------------------------------------------------------
'Function Name                    : LastRowInColumn(col_no, sheet_name, Optional dtype = 0)
'Function Description             : Excel Function to find Last Row in Column
'Data Parameters                  : col_no:- Specify the column number
'                                   sheet_name:- Specify the name of the sheet
'                                   dtype:- 0 to return row number, 1 to return last row content, 2 to return last row address
'------------------------------------------------------------------------------------------------------------------------------
Public Function LastRowInColumn(col_no, sheet_name, Optional dtype)
    With Worksheets(sheet_name)
        LastRow = .Cells(.Rows.Count, col_no).End(xlUp).Row
    End With
    Select Case dtype
    Case 0
        LastRowInColumn = LastRow
    Case 1
        LastRowInColumn = Range(Split(Cells(, col_no).Address, "$")(1) & LastRow).Value
    Case 2
        LastRowInColumn = Replace(Range(Split(Cells(, col_no).Address, "$")(1) & LastRow).Address, "$", "")
    Case Else
        LastRowInColumn = LastRow
    End Select
End Function

Function Usage

Example usage of excel function to get Last Row in a column
Example usage of excel function to get Last Row in a column

To return Last Row Number
=LastRowInColumn(2, "Sheet1", 0)

To return Last Row Value
=LastRowInColumn(2, "Sheet1", 1)

To return Last Row Address
=LastRowInColumn(2, "Sheet1", 2)

COMMENTS





Name

AngularJS,3,Automation Testing,8,CSharp,5,Disqus,1,Excel,2,HP ALM,5,HTML5,1,ISTQB,2,Java Script,2,Manual Testing,7,Photography,1,Quiz,2,REST API,5,Testing,15,UFT,8,VB,5,VBScript,1,Wordpress,1,
ltr
item
Aneejian: Excel Function to find Last Row in Column
Excel Function to find Last Row in Column
Excel custom function to find last row in the specified column. Function can return last row number, last row content and last row address.
https://1.bp.blogspot.com/-T5IEYJTLk7I/WMfzR9LJ2OI/AAAAAAAAAEQ/57ZH988-KfAGjIQ4crTZFgmv9Z3vNnjggCPcB/s1600/lastrowincolumn.jpg
https://1.bp.blogspot.com/-T5IEYJTLk7I/WMfzR9LJ2OI/AAAAAAAAAEQ/57ZH988-KfAGjIQ4crTZFgmv9Z3vNnjggCPcB/s72-c/lastrowincolumn.jpg
Aneejian
http://www.aneejian.com/2012/11/excel-function-to-find-last-row-in-column.html
http://www.aneejian.com/
http://www.aneejian.com/
http://www.aneejian.com/2012/11/excel-function-to-find-last-row-in-column.html
true
5798203121010168414
UTF-8
Loaded All Posts No posts found VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU ARCHIVE SEARCH ALL POSTS No post found which matches with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy