My goal with this is to copy two Excel files to DataTables. dtPrimary and dtPrevious.
If Column 5 in dtPrevious Matches dtPrimary I wish to delete the line from the DataTable. So my Flow goes like this:
For Each Row in dtPrimary
For Each Row in dtPrevious
IF Row.item(5).ToString = line.item(5).ToString
(Assign) varDuplicateRow = Row
(Remove Data Row) Row:varDuplicateRow. Datatable = dtPrimary
But I get the following Error Message:
If: This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.
For each row in dtPrevious, you initialize a Boolean variable varMatchFound to False.
You then iterate through each row in dtPrimary to check if there is a match in Column 5 between the current row in dtPrevious and any row in dtPrimary. If a match is found, you set varMatchFound to True and break out of the inner loop using the “Break” activity.
After the inner loop completes, you check the value of varMatchFound. If it’s True, it means a match was found in dtPrimary, so you remove the corresponding row from dtPrimary.
This approach ensures that you only remove rows from dtPrimary when a match is found in dtPrevious and avoids the error you encountered.
It will only be the one field it’s checking though as the info in the other fields will be different. Essentially, when both Data Tables have been compared, anything where a specific field is the same (regardless of what the others say), I wish to delete the complete line