To resize a table range in Excel VBA, set the ListObject.Resize method on the table object: ActiveSheet.ListObjects("Table1").Resize Range("A1:D20"). That one line expands or shrinks the table so its body covers the range you specify, keeping the header row and totals row in their configured positions. The range you pass must include the header row and, if the table has one, the totals row, and the top-left cell of your range must match the table's current top-left cell.
This matters because typed data below a table is not part of it by default. Formulas, filters, formatting, structured references and pivot caches all stay tied to the table's defined range, so a table that never grows stops picking up new rows. Resizing by code is the reliable way to keep that definition accurate after imports, appends or deletes. Menu labels vary slightly by Excel version and region, but the VBA object model described here is stable across current desktop releases.
What You'll Need
- Excel desktop for Windows or Mac with a workbook that contains at least one Excel table (select your data and use Insert > Table if it does not).
- The Developer tab visible: right-click the ribbon and choose Customize the Ribbon, then tick Developer.
- Macro security set to allow macros in your own files, or the workbook saved as .xlsm.
- Your table's name, found in Table Design (called Table on some versions) in the Table Name box. Default names are Table1, Table2 and so on.
- A backup copy of the workbook. Resize changes what belongs to the table, and an incorrect range can silently shift data ownership.
Step-by-Step
- Name the table. Click any cell in the table, open Table Design and type a clear name such as
tblSalesinto the Table Name box, then press Enter. Spaces and most punctuation are rejected, so use letters, digits and underscores. - Open the editor. Press Alt+F11 (Windows) or Option+F11 (Mac) to open the Visual Basic Editor. In the Project pane, find your workbook and use Insert > Module for a general macro.
- Write the basic resize. Add a procedure such as
Sub GrowTable()containingDim ws As Worksheet,Set ws = ThisWorkbook.Worksheets("Data")andws.ListObjects("tblSales").Resize ws.Range("A1:F40"). Replace the sheet name and range with your own. - Check the corners align. The range's first row must be the header row and the range's first column must match the table's current first column. If your table starts at B3, the range must start at B3, not A1. A mismatch raises a runtime error.
- Include the totals row if present. For a table with a totals row, extend the range one row further than your data so the totals formulas have somewhere to live. For example, data from row 3 to row 30 with headers at row 2 and totals at row 31 needs a range ending in row 31.
- Run it. Press F5 with the cursor inside the procedure, or use Developer > Macros to pick the name. Watch the table borders in the sheet to confirm the blue table styling now covers the new area.
- Make it dynamic. Instead of a fixed range, calculate the last used row with
ws.Cells(ws.Rows.Count, "A").End(xlUp).Rowand build the range withws.Range("A1:F" & lastRow). This adapts to whatever your data import produces each time. - Test both directions. Run the macro with fewer rows than the current table to confirm it shrinks without leaving orphaned formatting, then with more rows to confirm it grows. Check that any chart or pivot table built on the table still reports the full range.
Common Mistakes
The most frequent error is passing a range whose top-left cell differs from the table's. Resize is not a move operation, so the anchor cell must stay fixed while only the bottom-right corner changes. If you need to move and resize, change the range's starting cell by resizing to the new coordinates and then verifying the header row still sits where formulas expect it.
Another common slip is forgetting the totals row, which causes Excel to push the totals formulas into the data area or drop them entirely. Equally common is writing the range relative to a different worksheet than the one holding the table; always qualify the range with the same worksheet object. Finally, hard-coding cell addresses instead of computing them breaks as soon as someone inserts a column, and mixing up the table name with the sheet name gives a "Subscript out of range" error.
Tips
Store the table name in a constant at the top of the module so you can change it in one place. Use Application.ScreenUpdating = False around loops that resize many tables, then restore it to True, since each resize triggers a screen repaint. When appending rows, it is often cleaner to add data to cells directly below the table and let the table auto-expand, then use Resize only when you need to include a deliberate gap or shrink the table.
Add a quick sanity check before resizing: compare the range's row count with the totals row setting using listObj.ShowTotals, and abort with a message if they conflict. Keep a module-level helper that returns the last row of a given column, so every macro uses the same logic. For tables fed by queries, be careful: a query-loaded table may reset its size on refresh, so resizing in code should not be the only mechanism you rely on.
Troubleshooting
If Excel reports a runtime error when the macro runs, check three things in order: the table name matches exactly, the range's top-left cell equals the table's current top-left cell, and the worksheet qualifier points to the right sheet. A "Subscript out of range" message almost always means a name mismatch. If the table resizes but formulas break, the range probably excluded or included the totals row incorrectly.
If nothing appears to happen, confirm the code ran at all by adding MsgBox "done" after the resize line. If the table grows visually but charts do not update, refresh the chart's data source or the pivot cache. If the workbook becomes slow, turn off screen updating as described above and check whether an event handler on the sheet is firing repeatedly. When behaviour is baffling, undo by pressing Ctrl+Z immediately, or restore your backup copy and step through the code with F8 to watch each line.
Frequently Asked Questions
Can Resize change which columns the table covers?
Yes. The range can be wider or narrower than the current table, but narrowing removes columns from the table, so any structured references to those columns will return errors. Widen carefully and update formulas afterwards.
Does Resize add or delete cell content?
No. It only redefines the table's boundary. Data outside the new range stays on the sheet but is no longer part of the table, and empty cells inside the new range become empty table rows.
Why does my macro fail when the table is filtered?
Resizing is generally allowed with filters applied, but hidden rows can make the visible result confusing. Clear filters first so you can see exactly what the new range contains.
What is the difference between Resize and adding rows?
ListRows.Add appends one row at the end and copies formulas down. Resize sets the whole boundary at once and is better for importing a block of data or shrinking a table after cleanup.
Can I resize a table on a protected sheet?
Not while the sheet is protected, because the operation changes the sheet structure. Unprotect the sheet in code with the correct password, resize, then protect it again. Be aware the password will be visible in your code.