I am currently attempting to add a table to the Data Model (in Power Pivot). The issue is a new table with a different name needs to be added every time the macro is run. Currently what the macro does is bring in a new sheet of data from an outside source. The table in the workbook is different each time. In bold is the static table that needs to be "dynamic." Is there a way to use the rng.select in this instance? Below is what I have:
Thanks.
Code:
'Add New Table to Data Model
Set ws = ActiveSheet
With ws
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
lCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set rng = .Range(.Cells(lRow, 1), .Cells(lRow, lCol))
rng.Select
End With
wrk.Connections.Add2 _
"WorksheetConnection_Vacancies_Report_A.xlsm!Vacancies_1014", "", _
"WORKSHEET;S:\Vacancy Project\Vacancies_Report_A.xlsm" _
, "Vacancies_Report_A.xlsm!Vacancies_1014", 7, True, False
Thanks.