Hi All,
I always find myself typing the following for getting the Lastrow when required
However, I have been learning to create functions recently, and I have been messing around and created the below
This could be used as follows
Do you think the above function would come in handy, if I am using the Lastrow count in multiple Sub Routines and Modules?
I always find myself typing the following for getting the Lastrow when required
Code:
ThisWorkbook.Sheets("xxx").Cells(Rows.Count, x).End(xlUp).Row
However, I have been learning to create functions recently, and I have been messing around and created the below
Code:
Function GetLastRow(ws As Worksheet, Target As Variant)
'This can be used to call (example below)
GetLastRow = ws.Cells(Rows.Count, Target).End(xlUp).Row
End Function
This could be used as follows
Code:
Lastrow = GetLastRow(ThisWorkbook.Sheets("Sheet1"), 1)
Do you think the above function would come in handy, if I am using the Lastrow count in multiple Sub Routines and Modules?