Data Import & Export

Import a Variable XLSM Range into Access with TransferSpreadsheet

Camila MilosovichCamila Milosovich Nov 25, 2026 869 views

Question details

Import a changing cell range from an XLSM workbook into an Access table using VBA.

Import a Variable XLSM Range into Access with TransferSpreadsheet
Product
Microsoft Access 2010
Device & OS
not provided
Scenario
A VBA procedure formats an Excel workbook and imports a range whose row numbers vary.
Observed behavior
The import requires a compatible spreadsheet type and a text range; error 3011 may occur if Access cannot find the specified object.
Before you start

Identify the XLSM file path, worksheet name, destination table, and first and last rows to import. Save any workbook changes before testing the transfer.

Solution 1Recommended

Pass the XLSM range as text to TransferSpreadsheet

Use the Excel 12 XML spreadsheet type and build the changing range from row-number variables.

1
Open the VBA procedure

In Access, press Alt+F11 and open the module containing the TransferSpreadsheet call.

2
Build a text range

Use an expression such as "A" & FirstTINonEmp & ":G" & NextEmp rather than passing an Excel Range object. Confirm that NextEmp is the last row you want to include.

3
Set the spreadsheet type

Use this call, replacing the table name and variables as needed: DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12XML, "tblResultImport", defaultPath, False, "A" & FirstTINonEmp & ":G" & NextEmp

4
Run the import

Run the procedure from the VBA editor, then open tblResultImport in Access to check the imported rows.

Header setting: The False argument tells Access that the first row of the imported range does not contain field names. Use True if that row contains headers.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Microsoft Office formats, making it easy to move everyday spreadsheet work to WPS. It does not fix Microsoft Access TransferSpreadsheet errors.

Open and work with Excel spreadsheet files in WPS SpreadsheetsCompatible with common Microsoft Office formats, including XLSXFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Which spreadsheet type should I use for an XLSM import in Access 2010?

Use acSpreadsheetTypeExcel12XML as the spreadsheet type in the DoCmd.TransferSpreadsheet call.

Can I pass an Excel Range object to TransferSpreadsheet?

No. Pass a text expression such as "A" & FirstTINonEmp & ":G" & NextEmp as the Range argument.

How do I import from a specific worksheet?

Include the worksheet name and a dollar sign in the range string, for example "Sheet1$A1:G10". Replace Sheet1 and the cell addresses with the values in your workbook.

Does error 3011 mean I need to copy the data to a new workbook?

Not necessarily. Check the file path, worksheet name, and range first. Save and close the workbook, then rerun the import to test whether its open state is involved.