I am trying to create a table on each of seven worksheets. Each sheet is a territory; the first column of the table is a company in the territory and each subsequent column is a product sold to that company.
Although all the data I want is selected just before creating the table, the "create table" code only includes the first two columns.
I tried adding the following to fix this problem, but I get an error:
ActiveSheet.ListObjects.Add(xlSrcRange, Range([#All]), , xlYes).Name = _
"Table1"
Why does this only include two columns?
Sub Find_Em()
'
' Find_Em Macro
'
Dim Salesman(7) As String
Salesman(0) = "Sally"
Salesman(1) = "Sandra"
Salesman(2) = "Susan"
Salesman(3) = "Suki"
Salesman(4) = "Samantha"
Salesman(5) = "Sutra"
Salesman(6) = "Sherly"
i = 4
Tbl_Name = Salesman(i) & "_QB_Table"
'a clumsy way to find the data I actually want to put into the new table
Cells(3, 150).Select
Selection.End(xlToLeft).Select
Last_Column = ActiveCell.Column
Range(Cells(3, 12), Cells(3, Last_Column)).Select
Range(Selection, Selection.End(xlDown)).Select
' the following actually makes the table. Although many columns are "selected" on
' the left-most 2 columns become part of the new table.
ActiveSheet.ListObjects.Add(SourceType:=xlSrcRange, _
Source:=Selection.CurrentRegion, _
xlListObjectHasHeaders:=xlYes _
).Name = Tbl_Name
End Sub