Find element exist in column and then write that row into new excel file

Hi Everyone.

Have a good day!

I have an exercise , pls support me to resolve.

I have some excel files in the same folder, I want to use For Each activity to check all of excel files exists in folder… When run process, it will show a Input Box and I will input the " Code " which I want to find … it will find this code in Column C of each excel file… If it found, it will write all row into new excel file.

Pls support me XAML file for this case.

Thanks in advance!1.xlsx (8.4 KB)
2.xlsx (8.5 KB)
Result.xlsx (8.2 KB)

Hi @trunghai.

  1. Use Directory.GetFiles(sourcePath, “*.xlsx”) to get all the excel files
  2. Create a data table (dtResult) to store the rows of the said code.
  3. Use Input Dialog to capture the code.
  4. Use For Each to loop to each file path.
    4.1 . Use read range and use the item.tostring as the file path
    4.2. Use a for each row to loop to the rows of the data table (dtCodes) containing the
    excel info.
    4.2.1 If row(“Code”).ToString = strCodeInput.ToString, Add Data Row
    4.3 Clear the Data Table (dtCodes)
  5. Use Write Range or Append Range to Results.xlsx.

I am not sure that this will be it but this is the logic.
I think it is best that you will do the robot configuration yourself and we will just assist you.
Thank you!

Hi @Jan_Brian_Despi

Sorry, I have created XAML file as below.

Could you pls support me to check & complete this XAML file ? Search & Write.xaml (9.7 KB)

Can you try this one? Search & Write.xaml (13.3 KB)

Hi @Jan_Brian_Despi

Thanks you but it has issue when I run process.

maybe the column name in the excel file has spaces.
It can be "Code " instead of “Code”.
Please check

Hi @Jan_Brian_Despi

I have checked but it not contain space.1.xlsx (8.5 KB)
2.xlsx (8.5 KB)

Search & Write.xaml (13.6 KB)

3 Likes

Hi @Jan_Brian_Despi

Thanks you so much… how did you fix this issue ?

1 Like

I just change the Range in the Read Range Activity to “” instead of “C2:C20”

Thanks you so much ^^

1 Like

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