Adding Dynamic Table to Data Model

BrittKnee

Board Regular
Joined
Dec 4, 2017
Messages
82
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:

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.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,216,729
Messages
6,132,383
Members
449,725
Latest member
Enero1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top