Inside the loop use a filter datatable and filter the dt with all four columns into a newdt…
If newdt.rowcount>1 then assign ‘currentrow("Remarks")="Skipped"
In the else part use another filter datatable and filter dr with only name and amount into a newdt…
If newdt.rowcount>1 then assign ‘currentrow("Remarks")="recheck"
Repeat same for only pv column in the else block of step4
I think it’s necessary to clarify case that meets multiple conditions .
However, for now, can you try the following sample? This returns same result as the above.
dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r("NAME").ToString,r("AMOUNT").ToString)).Where(Function(g) g.Count>1).SelectMany(Function(g) g).ToList.ForEach(
Sub(r)
r("REMARKS")="RECHECK"
End Sub
)
dt.AsEnumerable.GroupBy(Function(r) r("PV").ToString).Where(Function(g) g.Count>1).SelectMany(Function(g) g).ToList.ForEach(
Sub(r)
r("REMARKS")="DUPLICATE"
End Sub
)
dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r("NAME").ToString,r("ID").ToString,r("PV").ToString,r("AMOUNT").ToString)).Where(Function(g) g.Count>1).SelectMany(Function(g) g).ToList.ForEach(
Sub(r)
r("REMARKS")="SKIPPED"
End Sub
)
Can you share screenshot of your workflow?
It might be better to use “ExcelApplicationScope” or “UseExcelFile” with Read/WriteRange instaed of Workbook-WriteRange. Can you try it?
How do I use write cell to add the remarks instead of rewriting the dt again ?
Because I’ll be using the same Excel forever. And initially I take only the rows with blank remarks as my transactiondata. I don’t process the ones with success remarks. So rewriting the dt might disturb the existing data.
Please let me know if you can connect via zoom for better understanding and quick solution.
dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r(“IBAN Number”).ToString,r(“Beneficiary Name”).ToString,r(“PV Number”).ToString,r(“Payment Amount”).ToString)).Where(Function(g) g.Count>1).SelectMany(Function(g) g).ToList.ForEach(
Sub(r)
If (String.IsNullOrEmpty(r(“Remarks”).ToString),r(“Remarks”)=“Skipped”,r(“Remarks”)).ToString
End Sub
)