Hello
I am writing a process which checks google for some information and than writes them to the proper cell in newly created column in excel sheet but if the data is not found it should write “error” or something in the cell. I have made conditions for that and “where to write” is set as a first cell in new column with autoincrement ticked on.
My problem is that when the condition is not met and it goes to else part, it writes the error messege again in the first cell of the column because it does not increment the cell counter in the else part when its going through main condition positively.
How can I fix it? To set the cell number in else part as the next one from the if incrementation?
Instead of using auto increment feature(this ideally works on incrementing in same sequence ), use a counter that you created to increment the cells or the for each loop properties will have a index property to assign a variable or for each row will have a variable already called currentIndex…these can used and the cell numbers can be incremented and use…the index starts from zero by default…so pleasee use write cell range as below if the data starts from A2
"G"+(currentIndex+2).ToString
So that the currentindex will change for each loop and gets incremented automatically
Instead of having Write Cell in the If / Else condition, have an Assign activity to set the value of a String variable to the value you want to write instead. E.g. If data is found, ValueToWrite = “Some value”, Else ValueToWrite = “Error”.
Then you can use one Write Cell activity below the If / Else condition, and “What to write” is the ValueToWrite variable.
This way the incrementing will always happen, and the value to write will be dynamically determined based on the preceding If / Else condition.
@yikwen.goo that is an interesting approach, i didn’t thought of that, it simplifies the process
@Anil_G thank you, that was exactly what I was looking for. I just wasn’t sure how to create the counter variable
@Harshith_Adyanthaya this seems a bit complicated for me, not sure how to exactly use it but I am at the very beginner level, I will keep it in mind for the future, thanks