Macro for Creating Tables in Excel 2007
Avoid using the select method
with ActiveSheet
set LastRow = .Range("A1").end(xldown)
set LastCell = LastRow.end(xltoleft)
set DataRange = .Range("A1",LastCell)
.ListObjects.Add(xlSrcRange, DataRange, , xlYes).Name = "Table1"
DataRange.ListObjects("Table1").TableStyle = "TableStyleMedium18"
End with
"MESTRELLA29" wrote:
Hi to all, I am downlading a File form external data and want to turn this
automaticlly in to table in excel 2007, when I run the macro this takes only
the selected range, but my download is never the same Size.
Take a look at what i have and please help correct it
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$J$57"), ,
xlYes).Name = _
"Table1"
Range("A1:J57").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium18"
|