I need to create a macro that selects all cells with data in them and formats as a table style medium 2. I have this code,
Sub A_SelectAllMakeTable()
    Dim tbl As ListObject
    Dim rng As Range
    Set rng = Range(Range("A7"), Range("A7").SpecialCells(xlLastCell))
    Set tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
    tbl.TableStyle = "TableStyleMedium2"
End Sub
But for some reason it picks up cells that don't have data in them and formats then in the table. Do you know why that might be?
 
    