Forum Discussion
WayneEK
Oct 04, 2019Copper Contributor
Excel Table Size in Macro
Hi, I download external Excel information and run a macro I created for it. It works great. However, the external info I download grows every week with new rows and when I run the macro, the new row...
Takmil
Brass Contributor
You can define a variable that contains the row number of the last row of the data. In this example I take the last populated row in column X:
Sub Something() Dim lastrow As Long
lastrow = Cells(Rows.Count, 24).End(xlUp).Row
End Sub
You can then use this variable in other portions of the code. e.g.
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$X$" & lastrow), , xlYes).Name ="Table1"