Read a excel cell and display the corresponding row

I need to get the correponding row values when i gave the input
cell value.But i got error .Can anyone help

use linq queries @rpa_developer1


Can you send screenshot of the workflow?

can you send any example workflow for this

can you provide the sample data?

Try like this
dt.Select("[Column-0] like ‘%"+searchStr.ToString+"%’").FirstOrDefault()(“ColumnName”)

Welcome to uipath community
Hope these steps would help you resolve this
—use INPUT DIALOG BOX activity and get the input from user with a string variable named str_input
—now use a Excel application scope and pass the file path as input
—inside the scope use a READ RANGE ACTIVITY and get the output with a variable of type datatable named dt
—now use a FOR EACH ROW activity and pass the variable dt as input
—use a assign activity inside the loop like this
Counter = 0
Where counter is a variable of type int32 with default value as 0
—inside the loop use a WHILE loop with condition like this
counter < dt.Columns.Count
Inside this loop use a IF condition like this

If true it will go to THEN part where we can use this WRITELINE activity

Then next to this writeline mention a BREAK activity inside the THEN part of if condition

Cheers @rpa_developer1

It works for 1st row only

1 Like

then remove that BREAK activity so that it will repeat for all rows
@rpa_developer1 not working

then it seems like you got that word only in that first row
is it so


1 Like

so thats working right buddy
@rpa_developer1 this possible to do this work using data function instead of foreach activity

1 Like

yah ofcourse
if we know at which column this would appear
if so the expression will be like this
str_output = String.Join("_",dt.AsEnumerable().Where(Function(a) a.Field(of string)(“yourcolumnname”).ToString.Contains(str_input.ToString)).First().ItemArray)

this will give only the first match
but if we have more than one then
dt= dt.AsEnumerable().Where(Function(a) a.Field(of string)(“yourcolumnname”).ToString.Contains(str_input.ToString)).copytodatatable()

now this dt will have only the rows with that column having that value we obtained from dialog box
any how now we will be in a position to pass this as input to FOR EACH activity like this
dt.Rows and change the type argument as System.Data.Datarow
–inside the loop use a WRITELINE activity and mention like this

Cheers @rpa_developer1

i am getting error when trying to fetch last two row.Here is my main workflow and data
Main.xaml (8.0 KB)
Annotation 2019-12-27 114058

And also i need to get the ID when i gave Value as input.What can i do

this statement will work actually may i know the issue you were facing