Look for value in one column and get it's respective value in another column

Hello everyone,
I’m having trouble doing a search in excel.
This is my table:

I have an excel where there are three columns. I would like to look for a certain value in all rows of column1 and if that value exists, get the corresponding value in column3.

So, according to the image of my table, if I look for the value “33” in column1, it should bring me the value “green”.

Remembering that the rows of all columns in this table are not constant, that is, the value 33 can appear in different rows, but it is always in column1.

Can someone help me please?

  1. Use Read Range to get your data into a datatable.

  2. Use a For Each Row activity to iterate over the rows.

  3. Put an If statement in the For Each Row activity with condition row(0).ToString = "33"

  4. If the condition is true, assign a string variable to row(2).ToString and do whatever you need to do with the value you’ve found.

2 Likes

@req7
at beginning you can use the filter datatable activity and filter the datatable on column1 for a particular value (dynamize it within a variable). For the returning rows you van retrieve the column3 value from corresponfing row

1 Like

Here is a one-liner for getting an IEnumerable(Of String) of distinct matching results for MyValue after you used ReadRange activity to get MyDataTAble :slight_smile:

From row In MyDataTable.Select(String.Format("column1={0}", MyValue)) Select row.Field(Of String)("column3") Distinct

I’m not ashamed :wink:

1 Like

Thank you all for helping me!! :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.