This is my sample data.
And this is the VBA code produced with macro.
Sub Macro1()
'
' Macro1 Macro
'
'
Range("A1:C3").Select
Application.CutCopyMode = False
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$C$3"), , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium9"
End Sub
How do I get the macro code?
- Developer > Record Macro
- Select all (ctrl + A) inside any cells within
A1:C3
- Home > Format as Table
Output
The problem is my data is dynamic and not necessarily stay at A1:C3
.
It could be bigger or smaller.
E.g., let say I've bigger within range A1:C4
in different Ms Excel file.
The code above won't select all, instead it selects only A1:C3
.
Last row A4:C4
won't be affected with this code.
How do I change this doesn't matter how big the table is?