Delete first 15 rows of a data table

Hi All,

I am facing issues while deleting first 15 rows of a data table . Can anybody help me with this?

Thanks in advance

Hi @atishaarav ,

Could you let us know What is the Method that you have tried and What Error are you receiving?

I tried using for each row and using remove data row activity inside it . However we cannot make changes to a DT while iterating through the same DT.

β€œFor Each Row: Collection was modified; enumeration operation might not execute.”

Got this error as result

Hi there @atishaarav,
I hope you are well.

You should be able to achieve this via:
YourDT = YourDT.AsEnumerable().Skip(15).CopyToDataTable

Though, you will want to check your DataTable contains enough rows.
If - YourDT.Rows.Count > 15 Then
YourDT = YourDT.AsEnumerable().Skip(15).CopyToDataTable

Please let me know if you have any questions.
Thanks once again for your support,
Josh

1 Like

@Mr_JDavey ,

It worked. Thanks a lot for quick solution

1 Like

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