Finding text and reading cell to the right

Hello,

I need to find text within column A and get the value to the right. I’m having trouble determining what that looks like within UiPath. Can someone walk me through what activities/expressions I should use? I’m aware that some text repeats. The values are the same so that’s okay.

Use Excel File, inside it Read Range (use headers unchecked) to read the Excel into a data table. Then For Each Row in Data Table to loop through the rows, with an If CurrentRow(0").ToString = yourText then you get the value with CurrentRow(1).ToString

Or instead of For Each Row you could Filter Data Table to keep just the rows with the yourText value in column 0.

You could also use the Remove Duplicate Rows activity (after reading into the data table) to eliminate the duplicate rows and then the For Each Row or Filter Data Table steps.

Hi @jenn.cruz

You can try this way:

Read Range (Output: DataTable)

For Each Row in DataTable
    If row("ColumnNameA").ToString().Contains("YourSearchText")
      Then
        Assign foundValue = row("ColumnNameB").ToString()
        Log Message "Found value: " + foundValue
        
    End If
End For Each

Hope it helps!!

Hi @jenn.cruz

  1. Read Excel File using Read Range Activity & Assign output variable DT as DataTable
  2. Take Assign Activity
    To store value= Assign Variable Text as String. And use below expression.

DT.AsEnumerable().Where(Function(row) row.Field(Of String)(0) = “SearchText”).Select(Function(row) row.Field(Of String)(1)).FirstOrDefault()

Note:
(0)= Column A (Column Index)
“SearchText” is your input text to match in Column A.
(1)= Value to Get from Column B. (Column Index)

For reference you can check below image

Hope it will helps you :slight_smile:
Cheers!!

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