Check if name exists in excel column

How can I create a function that checks if a certain name (e.g. “Mike”) is in column D of an Excel file? And if the name is in it, it should write in the same column D under the last entry “User exists”.

Thank you!

Hello @lope_0238 , welcome to the UiPath Communitiy.

Try the following: Inside an Excel Application Scope use the Read Range to fill in an Data Table. Use the for each row to loop through the data table rows, use and if statement to check the value, if it is what you want use the write cell activity. Any question please let me know

Thank you! I already created the first part as you told, but what do I write in the if statement?

Hi @William_Blech_Sister use this condition

if(CurrentRow(“YourColumn”).ToString=“YourName”))

Hi @lope_0238 ,

Maybe an Alternate Solution would be to Check the value existence using a Linq Any() method and then perform a Write Cell on the Last Entry.

  1. Assuming Data in the Excel Sheet is read as a Datatable, say DT. We can use the below Expression to Check if the value exists in the Specified column.
DT.AsEnumerable.Any(Function(x)x("ColumnName").ToString.Equals("Mike"))

The Above Expression could be directly used in an If Activity.

  1. Next, In the Then Block of If Activity, you could use Write Cell Activity to Write the Entry “User Exists” on the last cell. A Skeleton the Implementation is shown below :
    image

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