How to do an Excel ReadCell/WriteCell sequence WHILE cells are not either empty or specific text?

I created a WHILE activity.

The conditions are
Not string.IsNullOrWhiteSpace(VarNum)
Not VarNum.Equals(“TOTAL”)

Inside the WHILE activity, there is an Excel activity that reads cells of column B one by one inside a sheet.

When the cell is either empty or has the word TOTAL, sequence should end.

If I leave the condition
Not string.IsNullOrWhiteSpace(VarNum)

it works very well. If it finds a blank cell, it ends the sequence and goes to another part of the flow (not inside the scope of this thread)

But if there is no blank cell, it reads and copies the cell with TOTAL and any cell coming after it.

So another condition to end the sequence is finding the word TOTAL.

However, using the condition Not VarNum.Equals(“TOTAL”) will ALWAYS give me an error if it finds a blank cell.

So… how to have a condition that if the cell has the word TOTAL, sequence will end, without casuing me an error if it finds a blank cell?

Fine
put the condition like this in while loop
Not string.IsNullOrWhiteSpace(VarNum) OR VarNum.Contains(“TOTAL”)

Cheers @Rogerio_Penna

Thanks, but I still get the error when it reaches a row where the cell is blank.

Fine
in the while loop put only this condition
Not string.IsNullOrWhiteSpace(VarNum)
and inside the loop use a IF condition like this
VarNum.Contains(“TOTAL”)
If true it will get into THEN part or it will get into ELSE part
based onthe condition we can place the sequence within either of these parts, that we have now inside the while loop

Cheers @Rogerio_Penna

I will try that. Thanks

it seems I do not know how to use IF activity.

I put the sequence inside the ELSE. Because IF VarNum = “TOTAL”, THEN sequence should end.

However, THEN is empty. And inside a WHILE loop. So if the cell is TOTAL, Uipath accesses the empty THEN part of the IF activity… and returns to the WHILE LOOP, because it still has not reached an empty cell (which is the pre-requisite to terminate the WHILE.

So, how do I get out of the WHEN activity . Is it possible that IF-THEN access some exit function??

ps: while I wrote the above sentence, I thought that maybe the IF-THEN could assign a blank value to VarNum, so when it reached the WHEN condition again, it exits the loop… I will try that.