Import an Excel Named Range into Access with a File Prompt
Question details
Let Access users select an Excel workbook and import a specific range into an existing table.

- 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.
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.
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.
In Excel, select the headers and data to import. Open Formulas > Define Name, enter DATA, choose Workbook as the scope, and save the workbook.
In Access, open the form in Design View, select the import button, and use its On Click event property to open the code builder.
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"
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.

Import a fixed cell range from a known worksheet
Use a worksheet and cell address instead of a named range when the source data always occupies the same cells.
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.

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.




