How to I make my variable return something depending on the number of each excel row


I’m a begginer and I use StudioX.

I use for each excel row activity. I need to have variable that for first row returns nothing, and then for row 2 returns (1) and then row 3 returns (2) for row 4 returns (3) and so on and so on.

How can I handle this?

Hi @anon40731888

You want to run the for each row from 2nd row right (ignoring 1st row)?

No sorry I will try to explain myself better:

I need to have text information stored in variable.

My automation starts with for each excel row activity.

And lets say it starts with a first row, then during this loop for first row I would need a variable that would be empty so it would store nothing.

Then for the next row so the second row, the variable would store (1)
then for the next row so the third row the variable would store (2)

this (1) (2) (3) is just a text that I need to use during each loop but for example on 66th row it would be (65). I can’t store this like that:


Because sometimes there are 100 rows and sometimes there are 10. And I would need to modify my excel all the time.

Do you understand? I’m sorry I’m new to this so its hard to explain.


For each row in excel:
    if(string.IsNullOrEmpty(Row("col name")) or String.IsNullOrWhiteSpace(Row("col name"))):
        assign: var = Nothing
        assign: var = Row("col name").tostring

Thank you!

Can you please help how to add this to my automation? I use the StudioX. Should I use set variable value activity?


Yes. Please refer this

I understand but are you sure this is correct?

I will not have data like this:

I will have only the first column with “number”. The second column (The text I need stored in a variable) will not exist it is just to show.


The type of the variable must be set to string and if the value present in the column then the variable holds “Nothing” else it holds value present in that current row. And the variable value change for each iteration.

If you want to store all the values in the column then you need to use collection variable.

Make sure to give the correct column name in the code.


Once check the attached workflow
Main.xaml (14.1 KB)

You can change the value in activity properties section or by opening the advanced editor by clicking the (+) in the activity.

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