Notifications
Clear all
VBA & Macros
3
Posts
2
Users
0
Reactions
857
Views
Topic starter
Hi,
I recorded a macro to create an excel table but the result is for a fixed range. I need to change the code so it goes to the last active cell.
How would this be rewritten? Thanks in advance for any assistance!
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$AD$88537"), , xlYes).Name _ = "Tickets" |
Posted : 29/06/2016 9:43 am
Try something like:
lRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
lCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
ActiveSheet.ListObjects.Add(xlSrcRange, Range(Cells(1, 1), Cells(lRow, lCol)), , xlYes).Name = "Tickets"
lCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
ActiveSheet.ListObjects.Add(xlSrcRange, Range(Cells(1, 1), Cells(lRow, lCol)), , xlYes).Name = "Tickets"
Posted : 30/06/2016 1:32 am
Topic starter
Hello Marrosi,
Thank you for your time and response. As a novice to VBA, once I realized that I first had to set the row and column dimensions to dim lRow as integer .
I was able to get it to work.
Have a good day!
Posted : 30/06/2016 12:12 pm