VBA runtime error, Listrows.Add

Sid1120

New Member
Joined
Dec 8, 2011
Messages
2
Has anyone ever run into this problem before?

I have an extensive .xlsm which uses the simple command line :
Code:
ThisWorkbook.worksheets(1).listobjects(1).listrows.add
And 2 out of 3 times, it will cause a run-time error which will then crash Excel and restart it.


The full piece of code is as follow (however even the simple example above bugs):

Code:
Dim iTable As ListObject
    Dim newRow As ListRow
    
    sheetsArray = getSheetsArray

For Each iSheetName In sheetsArray
        Set iTable = ThisWorkbook.Worksheets(iSheetName).ListObjects(1)
        
        Set newRow = iTable.ListRows.Add(Position:=iTable.ListRows.Count + 1)
        
        transferDataToRow newRow, iTable
Next iSheetName



Has anyone ever had this bug, which seems to be more of an Excel instability then an error with the code?

Any solutions? The fact that I cant add listrows to listobjects seems pretty disastrous!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,215,368
Messages
6,124,520
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top