Hi.
I can clarify that solution, and improve on it, cause there is a flaw which will give you an error if the table does not contain a row with that value.
Let’s assume you have a key word to identify the row you want to delete.
headerKey = "Invoice Number"
the variable can be initialized in an Assign or in the Default value when you create it.
Then, using that variable, you can find the row using .net and assign that to an Array of DataRows
Assign: headerRows = datatableVariable.AsEnumerable.Where(Function(r) r(0).ToString.Trim.ToUpper = headerKey.Trim.ToUpper).ToArray
Then, you need to check to make sure you found a match, otherwise it will throw an error. And, use the indexOf() the last item in the array of rows to skip to, then .CopyToDataTable()
If headerRows.Count > 0
Then,
Assign: datatableVariable = datatableVariable.AsEnumerable.Skip( datatableVariable.Rows.IndexOf( headerRows(headerRows.Count-1) )+1 ).CopyToDataTable
If you have any errors, please post them, and we can easily identify the problem.
The alternative solution to this, is to copy the table to a new variable, then loop through the original table, but delete from the new variable, until you get to the header key word.
So, that would look like this:
newDatatable = datatableVariable.AsEnumerable.CopyToDataTable
For each row In datatableVariable.AsEnumerable //TypeArgument DataRow. Use Output property for index
Delete row //using index of ForEach, use: newDatatable.Rows.IndexOf(index)
If row(0).ToString.Trim.ToUpper = headerKey.Trim.ToUpper
Break activity
Regards!