0

I am adding a new row to a table but want to then add the data to that row that I just added. I am thinking something like this, but not sure how to add each columns data to that new row. My table has 4 columns named "store" "emp#" "date" & "amt". I have specific data that I will put in each column. I simplified the code, as there is a whole lot more to the macro, but just stuck on this part. Thank you for you help.

Dim rt_ws As Worksheet
Dim rt_tbl As ListObject

Set rt_ws = ThisWorkbook.Worksheets("RT Clock Hours")
Set rt_tbl = rt_ws.ListObjects("rt_hours")

With rt_table.ListRows.Add

    .  `this is where I am not sure what to do`
    .
    .

End Sub

1 Answer 1

1

Try this code

Sub Test()
    Dim ws As Worksheet, tbl As ListObject

    Set ws = ThisWorkbook.Worksheets("RT Clock Hours")
    Set tbl = ws.ListObjects("rt_hours")

    With tbl.ListRows.Add
        .Range = Array("Store1", "1530", "05/03/2020", "Amt1")
    End With
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

I think .Resize is redundant. Shouldn't the .Range property of the ListRow object already be the same column size as the Table?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.