Worksheet Connections

Milo1984

New Member
Joined
Sep 4, 2017
Messages
7
Hi,

can you please help me with replacing the worksheet data below to point to the current workbook and worksheet?

It won't only be me running the code.

Code:
  Workbooks("Test.xlsm").Connections.Add2 _
        "WorksheetConnection_Test.xlsm!Table1", "", _
        "WORKSHEET;C:\Users\xx\xxxx\Excel1\Test.xlsm" _
        , "Test.xlsm!Table1", 7, True, False
    Sheets.Add
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlExternal, SourceData:= _
        ActiveWorkbook.Connections( _
        "WorksheetConnection_Test.xlsm!Table1"), Version _
        :=6).CreatePivotTable TableDestination:="Sheet5!R3C1", TableName:= _
        "PivotTable2", DefaultVersion:=6

Many thanks in advance
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,

sorry to keep asking, but can someone say if it is possible or not, otherwise I will need to find an alternative solution.

to re-iterate. Instead of "test.xlsm" and "
C:\Users\xx\xxxx\Excel1\Test.xlsm
" I need it to simply reference the current workbook. Is this possible?
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,394
Members
449,155
Latest member
ravioli44

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