Add data row to specific row index in data table

Hello,

I have the following activities that add and remove data rows in specific locations in Excel:

I would like to achieve exactly the same but for a data table

I have configured the remove data row:
image

But I cannot add a data row in a specific location in the data table as this option does not seem to exist in this activity:
image

Please advise how I can achieve this

Cheers

Hi @E.T.S

Try this in Invoke Code:

dt.Rows.InsertAt(dt.NewRow(), Math.Min(intRowsIndex + 7, YourDataTable.Rows.Count))

If possible share the input and expected Output file

Regards

1 Like

Hi @E.T.S

If you want to add the row at particular index then try this

DT.Rows.InsertAt(DT.NewRow(), Index)

Add Data Row activity wont add the row at particular index

Input:

image

Output:

image

Regards,

Create new row using
newRow (DataRow)=dataTable.NewRow()

To insert datarow at a specific index
dataTable.Rows(index)=dataTable.Rows.InsertAt(newRow, index)

This works perfectly to give me the output I need thanks!

1 Like

You’re welcome @E.T.S

Happy Automation!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.