Row Index read one column return another

Hi,

I have two columns in Excel. How to read Column G based on user input variable then output value in column H?

image

For example,
Arr input = {“A”, “D”}
then I want {“111”, “444”} as output

I read excel and put the data into a datatable, then what?
I have trouble getting the row index of column G based on input, please help.
After getting the row index, I am thinking to use for loop and get row item for Column H.

I have 2018.1 version

Thanks!

Lavina

  • Use Input Dialog activity to get input.
  • Assign String2 = Datatable1.select("[Column7]=’" + userInput.tostring + "’).item(“Column8”).tostring
3 Likes

Hi,

Thanks for your response!
Your syntax doesn’t work.
image

I have imitated yours and tried this method but got an error:

dt.select("[ID]=’" + “’” + idStr + “’”).Item(“Invoice ID”).ToString

image

test is a str.

Also, please note that although user’s input is a string, but the string has to be split into array because (as in my original post):

Str = “A, D”
StrArr = {“A”, “D”}
Then I can find the corresponding number in column H (“111”, “444”)

Can anyone help? Thanks

Lavina

If you already have string array for user input u can
1.use for each for array
2.us for each row activity inside array foreach take datatable which is read from excel
3.if row.item(0).ToString =item.tostring
Inside if use write line row.item(1)

This is will.work only if your data table has just 2 columns else change column indexe to appropriate values

Use the below code :slightly_smiling_face:

  • For each row in dt
  • If StrArr.contains(row(0).tostring)
  • In writeline - row(2).tostring