Data Import & Export

Import an Excel Named Range into Access with a File Prompt

Huda QurayshiHuda Qurayshi Nov 25, 2026 870 views

Question details

Let Access users select an Excel workbook and import a specific range into an existing table.

Import an Excel Named Range into Access with a File Prompt
Product
Microsoft Access and Microsoft Excel
Device & OS
not provided
Scenario
An Access user selects a workbook whose file name may change and imports its order data into TBLorders.
Observed behavior
Using DATA as the Range argument produces error 3011 when Access cannot find that named object in the selected workbook.
Before you start

In Excel, confirm that each source workbook contains a workbook-scoped named range called DATA. Include column headers in that range and check that they and the data types match the fields in the existing TBLorders table.

Solution 1Recommended

Prompt for an Excel file and import the DATA named range

Use this approach when each selected workbook has the same workbook-scoped named range.

A worksheet name is not automatically a named range. The Range argument must identify an existing named range or a valid worksheet range in the selected workbook.

1
Define the source range

In Excel, select the headers and data to import. Open Formulas > Define Name, enter DATA, choose Workbook as the scope, and save the workbook.

2
Open the Access form's VBA editor

In Access, open the form in Design View, select the import button, and use its On Click event property to open the code builder.

3
Add the file picker and import code

Add this code to the button's Click event procedure: Dim fd As Object Dim filePath As String Set fd = Application.FileDialog(3) With fd .Title = "Select an Excel workbook" .Filters.Clear .Filters.Add "Excel workbooks", "*.xlsx" .AllowMultiSelect = False If .Show <> -1 Then Exit Sub filePath = .SelectedItems(1) End With DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "TBLorders", filePath, True, "DATA"

4
Test the import

Open the form in Form View, click the import button, and select an .xlsx file. Open TBLorders to verify that the expected records were added.

Prompt for an Excel file and import the DATA named range
If error 3011 appears: Open the selected workbook in Excel and check Formulas > Name Manager. Confirm that DATA exists with workbook scope and refers to the intended cells; a worksheet tab named Data alone does not create the named range.
Free Microsoft Office alternative

Prepare Excel Source Data with WPS Spreadsheets

WPS Office is a free, lightweight, easy-to-use alternative for working with spreadsheet files. Its familiar interface and Microsoft Office format compatibility help you move existing workbooks into WPS. Access is still needed to run the database import.

Review and edit spreadsheet data before an Access importOpen and save Microsoft Excel XLSX filesWork in a familiar spreadsheet interfaceUse a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why can't Access find DATA in my workbook?

DATA must exist as a named range in the selected workbook. In Excel, open Formulas > Name Manager and verify the name, its workbook scope, and the cells it references. A worksheet tab named Data is not itself a named range.

Can users choose a different workbook each time?

Yes. Use Application.FileDialog(3) to show a file picker, then pass the selected path to DoCmd.TransferSpreadsheet. Each selected workbook must contain the range specified by the code.

What does HasFieldNames set to True mean?

It tells Access to treat the first row of the specified range as column headings. Include the headings in the range and ensure they match the destination table's fields.

Can I use a worksheet range instead of a named range?

Yes. In the TransferSpreadsheet Range argument, specify the worksheet and cells, such as "Data$A1:D100". The sheet and address must exist in the selected workbook and cover the data you want to import.

Can WPS Office run the Access import button?

No. The VBA button and DoCmd.TransferSpreadsheet command run in Microsoft Access. WPS Spreadsheets can be used to work with the Excel source file, but it does not replace Access for this database operation.