I wrote a short VBA code to automate stuff.
A short snippet is as follows:
Sub TEST()
Rows("1:2").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$O$148"), , xlYes).Name = _
"Table2"
End Sub
However, every Excel file differs with regards to the number of rows. Now when I recorded this macro it just takes the range of $A$1:$O$148. How can I adjust this part so that it automatically recognizes the last row and/or range?
I already tried:
.Range("A1").SpecialCells(xlCellTypeLastCell).Row
Instead of:
Range("$A$1:$O$148")
Thanks in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…