For each row stop after last row

Hello everyone,
I have created a BOT which works, however, I am having a slight issue which I am unable to resolve. I have an excel file with data. I am using ‘Read Range Workbook’ and ‘For Each Row’. It reads through the excel file, it takes the info, and puts it into an application, saves, duplicates the record, and continues onto the next row of data, enter all the data needed, SAVE- DUPLICATE and so on…now, after it reads the last row of data and it SAVEs, I want it to stop, however, it continues to hit DUPLICATE(which is a button on the application where it puts all the data that it reads from the excel file, and when it tries to read the excel file, there is no data and it hangs. How can I tell it to stop after it copied the last row of data from the excel file?

@rezart_mersini

If there is no other loop sometimes if the excel data is filled and deleted from cells then those rows also would be read so more rows than available times it is trying to loop…

So try to use a if condition inside…checking String.IsNullOrEmpty(currentRow("ENTITY").ToString

And on then side use break…

Cheers

thanks, I have never used BREAK…I will get back with an update

1 Like

@Anil_G here is what I did, and I must be doing something wrong as it still does the same. I thought that once the IF statement is TRUE (meaning, the row ENTITY is blank , it will send me an email with the attached excel file and continue to log out (I have completed these activities below but they are not visible in the image I have attached.) If the IF statements is false, it should continue outside the IF LOOP with duplicating the record and so on…or am I missing something here?

First, you need to check once you reading the Excel data check your data table and remove the empty rows.

After that, you can go for each activity, and then you need to check some value that exists and then process the next

@ rezart_mersini
please check in logs what you are getting some time you receive ’ ’ space value then you need to remove it

@Anil_G @mukesh.singh thanks for you suggestions but that is slightly above my knowledge at this time…I thought the IF ELSE loop is straight forward…if TRUE do this, ELSE do this, but it seems there is little bit more work required.

@mukesh.singh my data table that contains all the data being read, does not have any empty rows, except the last one, obviously.

@rezart_mersini

After the loop hits break it would end and would not go to send email…send email and logout can be placed outside for loop

Cheers

1 Like

If you want to set it up as IF THEN ELSE, then you can remove the Break activity.

IF TRUE then send email, ELSE continue with the duplicating record activities.

1 Like