Condition Error


I am trying to add a condition into an existing bot because a few times it has opened the excel file and the file has somehow gone blank (and it shouldn’t). So I added an if activity and have the normal flow in the then side and an error email in the else side. However, on the condition I am getting an error. There should always be data in cell A1, so I am trying to write it if A1 is not blank go with the normal process on the then side, if it is blank, do the else. But I am getting an error in my condition.

Thanks for your help!

Hi! It may be due to the scope of the A1 variable :slight_smile:

Hi, so in the formula it is taking A1 as a variable which isnt declared.

You would need to read the cell first and use that variable in the if statement.

Or as @Jan_Brian_Despi mentioned, the scope could be wrong.

1 Like

@Jan_Brian_Despi @TimK I had a read range for the entire sheet but didn’t realize I needed a read cell. I added that below my read range. But now the error has changed.
Here is what I added (I created a variable for A1) and here is the new error.

Hi @sdickson
Just use A1 isNot Nothing in the condition instead of if(A1 isNot Nothing) :slight_smile:


ps-I do have a workbook path I just deleted it for the screenshot :slightly_smiling_face:

@sdickson I would try not to use double negatives where possible. Instead of doing IsNot Nothing. Just use the method IsNothing(). Then flip the side you’re working on.

Also, I’m not sure Nothing is what you want to be using for this. Nothing is used only for null objects/references and that values can’t be null. If A1 contains a string, then you should use String.IsNullOrWhiteSpace(YourA1Variable) instead. This will check if it returns null, spaces only, or string.empty

If it is a number in A1 then that is a value and thus cannot be Nothing. So if YourA1Variable is of type integer or decimal or double, then it could never be null. If A1 was blank it would set the variable to it’s default value (which i believe is 0 for all number types)

1 Like

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