How to get cell value if required data is available in Excel using linq Uipath

Hi Team,

I have one excel with few data .I need to check some data is available in Column A . If data is available I need to extract the cell index.

Using linq query(Assign activity) I need to extract the cell index and output will be in Int type.

For example if data is A11277 is available in ColumnA
I need to extract the cell index.


Attached is the screenshot for your reference.

Kindly suggest.

getting first index (-1 if not found)
intIDX =

dtData.AsEnumerable.ToList.FindIndex(Function (x) x("Name").toString.Trim.toUpper.Equals("YourName".toUpper.Trim))

@Baby123

Read Excel File:

Use the “Read Range” activity to read the Excel file into a DataTable, let’s call it excelDt.

Specify the Value to Search:

Define the value you want to search for, such as “A11277”.

LINQ Query:

Use a LINQ query to search for the value in Column A of the DataTable and get the index of the first occurrence.

excelDt.AsEnumerable().Select(Function(row, index) If(row(“ColumnA”).ToString() = “A11277”, index + 2, -1)).FirstOrDefault()

  • excelDt.AsEnumerable(): Converts the DataTable into an enumerable collection of DataRow objects.
  • Select: Projects each DataRow into a new form. We check if the value in “ColumnA” matches the search value. If it does, we return the index of the row plus 2 (since row indices in Excel start from 1 and LINQ uses zero-based indexing). If not, we return -1.
  • FirstOrDefault(): Returns the first element of the sequence or a default value (-1) if no element is found.

Extract Cell Index:

Store the cell index in an Integer variable.

How to pass variables in selectors.

I my selectors sometimes I am getting idx value . sometimes it won’t come.

So I need to pass the idx value dynamically using variable.

Can any one Suggest how to pass idx value using variable.

@Baby123

Check this video