Find Row Index and Column Index by cell value only

Prepare an empty datatatable with build datatable and configure the following columns:
search (string) ,ridx (int32), cidx (int32) - dtReport

Prepare a variable
arrSearchKeys | String Array = new String(){“AMOUNT”, “TOTAL”}

Assign Activity
dtReport =

(From c in Enumerable.Range(0, YourDataTableVar.Columns.Count)
From  s in arrSearchKeys
Let i = YourDataTableVar.AsEnumerable.ToList.FindIndex(Function (d) d(c).Tostring.ToUpper.Trim.Equals(s))
Where i > -1
Let ra = new Object(){s, i, c}
Select r = dtReport.Rows.Add(ra)).CopyToDataTable

Handling empty result:
:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

1 Like