How do I move down a row in Excel to check next value?

excel

#1

Hi,
We use Excel a lot at my work. So most of my work with UiPath will involve Excel and reading rows. I will have a column (Say column G) that says Yes or No(or if it is easier it can be blank). If it says Yes, then the robot should go to the next row and see if it says Yes or No. If it says Yes, then check next row etc. But if it says No(or is blank) I want the robot to perform a task, when the task is completed I want the robot to write Yes in the column and then move down and check if the next row has Yes or No. And so on.
But to start I only want to learn how to check if column G has Yes or No, and if it has Yes to move down one row and check again.
Any ideas? I understand that I should use “For each row” but I cannot find a way to read what is in the column G for the current row. I have trid to Read Cell, but then I need to specify which row. But the row should change to the next row if the value is Yes.
Kind regards,
Anna


#2

First, use a read range activity to get a datatable, then, use a for each row activity to go through all of it.
Use an If activity with the following condition: row(5).toString=“Yes”.


#3

Thank you, I think that is a good start.
I want to set if row(5).toString=“No”, then write “No” in the same row as No, but in say column K. And if it is Yes, then I want to use the Else part to write “Already handled” in the row but in column K. How do I write that?
Kind regards
Anna


#4

Use an excel application scope activity, then, a write cell activity inside it with the range “K”+theNameOfDataTable.rows.indexof(row).toString.


#5

Thank you so much for your assistance. It almost works! I have a “No” in G3, but the “No” I want to write in K3 is written in K1 instead. How do I manage to change the “K”+theNameOfDataTable.rows.indexof(row).toString. so that the “No” is written 2 rows below? I tried to add +2 at the end, but it is not accepted.


#6

“K”+(theNameOfData.row.indexof(row)+2).toString.


#7

It works :slight_smile:, thank you so much for your assistance. I will be able to use this for almost all of my robots going forward.


#8

you’re welcome