-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlastRow.bas
More file actions
19 lines (15 loc) · 852 Bytes
/
Copy pathlastRow.bas
File metadata and controls
19 lines (15 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'''''''''''''''''''''''''''''''''''''''''''''''
' Get Last Row In Column '
'''''''''''''''''''''''''''''''''''''''''''''''
' *** Requires Function "getColumnLetter" ***
'recieves input of worksheet (ex. "Sheet 1") and column range (ex. "A:A") as string
'outputs last used row number as long
Function lastRow(searchWorksheet As String, searchColumn As String) As Long
'dimension variables
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet: Set ws = wb.Sheets(searchWorksheet)
'find the column letter of the search column
Dim searchColumnLetter As String: searchColumnLetter = common.getColumnLetter(ws.Range(searchColumn).Column)
'find and return the last row in the search column
lastRow = ws.Range(searchColumnLetter & Rows.Count).End(xlUp).Row
End Function