# Run-time Error 1004



## hajiali (Sunday at 1:32 PM)

```
With ws.ListObjects("Elist")
    With .ListRows.Add
        .Range(.Parent.ListColumns("FIRST NAME").Index) = TextBox2.Value
        .Range(.Parent.ListColumns("LAST NAME").Index) = TextBox3.Value
        .Range(.Parent.ListColumns("DOB").Index) = TextBox8.Value
        .Range(.Parent.ListColumns("PHONE LIST").Index) = TextBox9.Value
    End With
End With
```

getting error on the following row

```
With .ListRows.Add
```

The strange thing is that it does add a row and when I click on Debug and press run it works and adds another row. I double check the Sheet is not protected. 

any suggestions is greatly apprecatied


----------



## hydraulicwave (Sunday at 2:29 PM)

Make sure that the ListObject named "Elist" exists on the worksheet. You can do this by checking the name of the ListObject in the Name Manager (in the Formulas tab).
Make sure that the ListObject named "Elist" has at least one row in the list. If the list is empty, the ListRows collection will be empty as well and you will not be able to add a new row using the Add method.
Make sure that the worksheet is not protected. If the worksheet is protected, you will not be able to add a new row to the list. You can unprotect the worksheet by right-clicking on the sheet tab and selecting "Unprotect Sheet" from the context menu.
Make sure that you have the necessary permissions to modify the list. If you do not have permission to modify the list, you will not be able to add a new row.


----------



## hajiali (Sunday at 3:38 PM)

> 4. Make sure that you have the necessary permissions to modify the list. If you do not have permission to modify the list, you will not be able to add a new row.


I double check all except #4. How do I check for that. the wired part is that after the Debug it will add the row and add the data to the table. its just that the error come up for some reason

Thanks for the feedback


----------



## hajiali (Sunday at 4:56 PM)

hydraulicwave said:


> Make sure that the ListObject named "Elist" has at least one row in the list. If the list is empty, the ListRows collection will be empty as well and you will not be able to add a new row using the Add method.


I think this was my issue I was excepting it to add one without having an empty row. this done the trick thanks.


----------

