I have a workbook (Excel 2010) with three tables in one of the worksheets. After working fine for some time, it will now not allow me to add rows to the first table. The first 5 lines of my procedure to do this are:
Sub AddMaterialRow()
Dim iTableRows As Integer, i As Integer
iTableRows = ActiveSheet.ListObjects(1).ListRows.Count
ActiveSheet.Unprotect
ActiveSheet.ListObjects(1).ListRows.Add
One reaching line 5, it gives the error message: Run-time error ‘1004’: This operation is not allowed. The operation is attempting to shift cells in a table on your worksheet.
The equivalent subroutines for the other two tables still work correctly.
Table 1 will also no longer allow me to insert table rows manually, although I can do so for the other two tables. Attempting to insert a row in the table gives me a pop-up text box containing the same error message text as given by VBA (without the error number). The table contains a mix of locked and unlocked cells, but that should not matter with the worksheet unprotected.
I made some changes to table 3 between the previous version that works and the current version with this problem, but table 3 still works fine in both versions.
What can be preventing me from inserting rows in table 1? Any ideas would be much appreciated.
Bookmarks