How to use for each to check excel file and use if else to move file to folder

Hi, I am new for Ui path, I need to check number in excel file, if no error will move the file to a folder else will move to another folder.

The rule is,
If all the values in column A are >10000000, then the file will move to >10000000 folder.
Else if have one of the value in column A is <10000000 the file will move to <10000000 folder.

Below are the Ui path i trying and the error i get. Thanks .

@horo1016 I guess what you are trying to do is Check each value in the ColumnA if it Contains Value <10000000 Then you’re moving the File, But What happens when you use a For Loop is The File is Moved Each Time as well, Hence You get the Error File Already Exists.

What you’ll need to do is Determine Whether at Least One Value in the Column Contains Value < 10000000, Then Move the File Once.

@horo1016 I suggest you to follow these Steps below :

  1. Create a Boolean Type Variable, say CheckValue

  2. For Each item in CheckNumber
    if (Cint(item)<10000000)
    Assign CheckValue = True

  3. Outside For Each Loop
    If CheckValue = True
    Move File to <10000000 Folder
    Move File to >10000000 Folder

These Steps should work considering this is what you needed :sweat_smile:

the step if look like this? or got which step i do it wrong ? :cold_sweat:

just use break activity after move file in if else part

the break put it like this?

Do one thing
just use move file activity in above if-else and after move file use break activity in both then and else part

use it in for each

1 Like

thanks, but i still get the same error :fearful:

its showing error because its open.
in UiPath if u are working on some file (text, excel,etc) and folder then it should be closed at the time of execution

I still have one more question, if let say i want change the >10000000 to = 8 digit. What should i write for the if condition?

I didnt get u, Its already 8 digit na

1 Like

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