How to Create an Excel Data Connection to Another Excel File – 3 Methods

This is the sample dataset.

dataset of excel data connection to another file


Method 1 – Using the Connections Function to Create an Excel Data Connection to Another Excel File

 

Using Connections Function to Create Excel Data Connection to Another Excel File

Steps:

  • Open a new workbook .
  • Go to the Data tab and select Existing Connections.

Using Connections Function to Create Excel Data Connection to Another Excel File

  • Select Browse for More.

Using Connections Function to Create Excel Data Connection to Another Excel File

  • Select the source file.
  • Click Open.

Using Connections Function to Create Excel Data Connection to Another Excel File

  • Choose the table in the dialog box.
  • Click OK.

Using Connections Function to Create Excel Data Connection to Another Excel File

  • Select Table and enter the destination in Existing Worksheet.
  • Click OK.

Using Connections Function to Create Excel Data Connection to Another Excel File

  • The table will be pasted:

Using Connections Function to Create Excel Data Connection to Another Excel File


Method 2 – Using a VBA Code to Create an Excel Data Connection

Steps:

  • Press Alt + F11.
  • Select the icon shown below.

Implementing VBA to Create Excel Data Connection to Another Excel File

  • Select Module.

Implementing VBA to Create Excel Data Connection to Another Excel File

  • Enter the following code in the module.
Sub ImportDatafromotherworksheet()
Dim ss_wkbCrntWorkBook As Workbook
Dim ss_wkbSourceBook As Workbook
Dim ss_rngSourceRange As Range
Dim ss_rngDestination As Range
Set ss_wkbCrntWorkBook = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set ss_wkbSourceBook = ActiveWorkbook
Set ss_rngSourceRange = Application.InputBox(prompt:="Select source range", Title:="Source Range", Default:="A1", Type:=8)
ss_wkbCrntWorkBook.Activate
Set ss_rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="A1", Type:=8)
ss_rngSourceRange.Copy ss_rngDestination
ss_rngDestination.CurrentRegion.EntireColumn.AutoFit
ss_wkbSourceBook.Close False
End If
End With
End Sub

Implementing VBA to Create Excel Data Connection to Another Excel File

Variables were declared to create a data connection to another Excel file and statements were used to apply the conditions.

  • Press F5 to run the code.
  • In the dialog box, select the file.
  • Click Open.

Implementing VBA to Create Excel Data Connection to Another Excel File

  • Select the source range.

Implementing VBA to Create Excel Data Connection to Another Excel File

  • Select the table: B4:D10.

Implementing VBA to Create Excel Data Connection to Another Excel File

  • The dialog box will show the source range:

Implementing VBA to Create Excel Data Connection to Another Excel File

  • Click OK.
  • Select the destination: B4.
  • Click OK.

Implementing VBA to Create Excel Data Connection to Another Excel File

  • The connected data table is displayed.

Implementing VBA to Create Excel Data Connection to Another Excel File

Read More: Excel VBA: How to Refresh All Data Connections


Method 3 – Applying the Power Query

Steps:

  • Open a new sheet.
  • Go to the Data tab.
  • Select Get Data.
  • Click From File.
  • Select From Excel Workbook.

Applying Power Query to Create Excel Data Connection to Another Excel File

  • Select the file and click Import.

Applying Power Query to Create Excel Data Connection to Another Excel File

  • In the Navigator panel, select Power Query.
  • Click Transform Data.

Applying Power Query to Create Excel Data Connection to Another Excel File

  • Go to the Home tab and select Remove Rows.
  • Choose Remove Top Rows.

  • Specify the number of rows to remove.
  • Click OK.

  • A preview is displayed.

  • Go to Transform.
  • Select Use First Row as Headers.

  • You can see the preview in the selected area.

  • This is the output.

 


Linking Excel Workbooks for Automatic Update

Two data tables from different workbooks were used:

Steps:

  • Copy the joining date in the selected area, as shown below.

  • Right-click the Joining Date column in Report-1.
  • Select Paste Special.

  • Select Paste Link.

  •  Joining Dates will be connected.

 

Read More: How to Create a Data Source in Excel


Download Practice Workbook

Download the workbook.


Related Articles

<< Go Back to Excel Data Connections | Importing Data in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Souptik Roy
Souptik Roy

Souptik Roy, a BSc graduate in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology, dedicated 1.5 years to the ExcelDemy project. During this time, he authored 50+ articles and reviewed 20+ for ExcelDemy. Presently, he is a designer and content developer at YouHaveGotThisMath and Brainor, sister concerns of ExcelDemy. His educational content spans science, mathematics, and grammar. Roy's interests include developing creative ideas, visualizing concepts with tools like Adobe Illustrator, and problem-solving within Microsoft... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo