A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
If row 1 already contains column headers (field names), change xlNo to xlYes.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I've recorded a macro and the result as as below:
Range("A1").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$AO$472"), , xlNo).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight13"
But instead of fixing the Range as ("$A$1:$AO$472"), how can I make it to select different range?
Thanks.
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
If row 1 already contains column headers (field names), change xlNo to xlYes.
Answer accepted by question author
If you want to turn the current selection into a range, change
Range("A1").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$AO$472"), , xlNo).Name = _
"Table1"
to
ActiveSheet.ListObjects.Add(xlSrcRange, Selection, , xlNo).Name = _
"Table1"
If you want to turn the contiguous range containing A1 into a table, use
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1").CurrentRegion, , xlNo).Name = _
"Table1"
The second one work but not sure why it added another row on top as a header? This is the code I used
Range("A1").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1").CurrentRegion, , xlNo).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight13"