(Solved) – New row in top of Excel table


I have a snippet of VBA code I’d like to enhance. Got two Excel tables – ToDo and Done. The code fetches first row in ToDo table (I use table header as anchor cell and offset one row down to get the value).

After some other features run, I want to add this value to Done table after which I delete it from the original ToDo table.

This all works – with the caveat that ListRows.Add function adds the new row to the bottom of the table as usual. Is there a way to add the new empty row & contents to the top of the Done table so that lastly processed values would run top-down, instead of bottom-up?

Some range reverse-order function probably messes up the overall sequence. Also adding a timestamp in .Range(2) and always do a sort feels too messy for workaround (there should be a neater way, right?)

Sub Data()

    Range("Data_transfer").Value = Range("ToDo_header").Offset(1).Value

    'some irrelevant code runs here

    Set newrow = ActiveSheet.ListObjects("Done").ListRows.Add

    With newrow
    .Range(1) = Range("Data_transfer").Value
    End With


End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *