Data Import & Export

Convert an Exported Excel Range to a Table Using Access VBA

Jason MillerJason Miller Nov 27, 2026 870 views

Question details

Convert fields exported from Access into an Excel table with sortable and filterable headings.

Convert an Exported Excel Range to a Table Using Access VBA
Product
Microsoft Access and Microsoft Excel
Device & OS
not provided
Scenario
Access VBA exports selected fields into specific cells in a new Excel workbook.
Observed behavior
The exported cells form a range that still needs to be converted into an Excel table.
Before you start

Check that the first row of the exported range contains column headings and that you know the final exported row. The example assumes the data is in columns A through C and that your Access VBA code already has a worksheet object named ws.

Solution 1Recommended

Create an Excel ListObject after exporting the data

Use this method to convert the exported range into an Excel table as part of the Access VBA export routine.

An Excel ListObject turns the range into a table, providing filter and sort controls in its header row. The example uses numeric values for Excel constants, so it can also be used with late-bound Excel objects.

1
Open the export routine

In Access, press Alt+F11 to open the VBA editor, then open the module or form code that creates the Excel workbook and writes the exported fields.

2
Identify the exported range

After the export finishes, set lastRow to the final row written by your routine. Adjust A1:C in the following code if your exported headings or columns occupy a different range.

3
Create and name the table

Add this code after writing the data, using your existing worksheet object and lastRow value: Dim tbl As Object Set tbl = ws.ListObjects.Add(1, ws.Range("A1:C" & lastRow), , 1) tbl.Name = "ExportedData" The first 1 specifies a range source; the second indicates that the first row contains headings. Choose a table name that is unique in the workbook.

4
Save and check the workbook

Save the workbook in your export routine, then open it in Excel and check that the table covers all exported rows and displays filter arrows in the headings.

Create an Excel ListObject after exporting the data
Use the actual final row: Ensure lastRow includes every exported record and that the target range does not overlap an existing Excel table.
Free Microsoft Office alternative

Review and filter exported spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Excel format compatibility, making it easy to open and work with exported files. The Access-to-Excel VBA automation itself requires Microsoft Office and is not fixed by WPS.

Open and review exported spreadsheet dataUse spreadsheet sorting and filtering toolsCompatible with Microsoft Excel XLSX filesFamiliar interface for an easier move from Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Why should the table be created after the export?

Creating the ListObject after writing the data lets you specify a range that includes the headings and all exported records.

How do I include more than three exported columns?

Change ws.Range("A1:C" & lastRow) to match the full exported range. For example, use ws.Range("A1:E" & lastRow) for columns A through E.

What does the last 1 in ListObjects.Add mean?

It specifies that the first row of the supplied range contains column headings, equivalent to Excel's xlYes constant.

Can I choose a different table name?

Yes. Change tbl.Name = "ExportedData" to a valid Excel table name that is not already used in the workbook.