Forum Discussion
Jodhvir
Jul 01, 2020Brass Contributor
Get Macro to select Last Row entry rather than a fixed one
Hi There. I made a macro which polishes some data I regularly import from the Web. However, its is hard-coded to select rows till 894. I wish to make it flexible, such that any entry which is the la...
- Jul 01, 2020
Try identifying the last row by adding the following code (the example uses column A for finding last row but use a column which you know will always be populated in your data):
Dim Lrow As Long
With ActiveSheet
Lrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Then you can address the range dynamically using:
Range("$A$1:$G$" & Lrow)
Charla74
Jul 01, 2020Iron Contributor
Try identifying the last row by adding the following code (the example uses column A for finding last row but use a column which you know will always be populated in your data):
Dim Lrow As Long
With ActiveSheet
Lrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Then you can address the range dynamically using:
Range("$A$1:$G$" & Lrow)