Reputation: 35
I want to preface this with the fact that I have no real VBA experience. I just research the Microsoft VBA reference documents and build my code piece by piece from there. I have created a user form to collect data that is entered into a table. I wanted to be able to go through each record and retrieve/update records as needed since information is typically gathered at multiple stages. I am getting an error on the below code (bold line erroring out):
Private Sub AddRecord_Click()
ActiveSheet.ListObjects("Status").ListRows.Add
**ModifyTableRow StatusTable.ListRows(StatusTable.ListRows.Count).Range**
UpdatePositionCaption
End Sub
I don't know what I am doing wrong and have not been able to troubleshoot on my own. I must be misunderstanding something.
Upvotes: 0
Views: 46
Reputation: 166835
ListRows.Add
returns the just-added row, so you can use that directly in a With
block
Private Sub AddRecord_Click()
With ActiveSheet.ListObjects("Status").ListRows.Add
ModifyTableRow .Range
End with
UpdatePositionCaption
End Sub
Upvotes: 1