I want to get an output of the Name of the person and only the Amount he/she has. I have done a For Each Row and contains to find “Mary” but I do not know how to skip column B and get the amount for “Mary”. How do you read excel cell horizontally?
The first thing you want to do is get the row index of “Mary” and you can do this with your IF statement inside of your for each row for when you’ve identified “Mary”.
Assign: MaryIndex = MyDT.Rows.IndexOf(row)
then its as simple as getting the value using MaryIndex:
Writeline: MyDT.Rows(MaryIndex).Item(2).ToString
EDIT: to give a better explanation:
MyDT.Rows(0).Item(0) = the A1 cell in Excel.
MyDT.Rows(2).Item(2) = the C4 cell in excel
Always start your row/column count at 0.
EDIT2:
I realised, depending on how you are looping through your rows (e.g. if you’re using a counter) you could simply:
You were almost done
Hope these steps would help you in this
—hope we have the datatable named dt ready on hand
—now use a for each row activity and pass the above variable as input
—inside the loop use a assign activity like this to get the name of the person str_Name = row(0).ToString
And another assign to get the Amount str_Amount = row(2).ToString
Are to get them as a string together we can mention this in a writeline activity inside the loop
“The Amount owned by “+row(0).ToString+” is “+row(2).ToString
Which would give us The Amount owned by John is $100.00