Variable excel selection


#1

Hi all,

Problem:
In some cases the robot should Read Range A1:AA1
In other cases it should it Read Range A2:AA2

This depends on the value of a certain variable (Variable type: Int32).

Is there a workaround? Because UiPath says that it is only possible to include string variables into this section.

Kind regards


#2

You can use if condition to validate that int32 variable condition and based upon that you can pass in below format.

if(intVar =2)
{

A+intVar.Tostring() : AA+intVar.Tostring()

}
else

{

A1:AA1
}


#3

Hello!

You can pass all on the Range Property directly: “A” & variable.ToString() & “:AA” & variable2.ToString()

Example:

variable = 2
variable2 = 4

Result: “A2:AA4”

Hope It Helps!

Regards,


#4

Thank you for your response. The problem with this solution is that the IntVar can go up to 100+
I’m not sure it is the best way to work with if? Or what is your opinion?


#5

Totally depends on what you want to do.Is your If condition variable and the excel variable(upto 100) the same? in that case you don’t need if codition, you can directly pass into.


#6

I already tried this, but I’m keep getting this Error message.

Is this because it’s not possible to Read Range twice on the same file in the same sequence?


#7

That sheet name you have mentioned in the read range is incorrect. (by default its sheet1 and you need to modify it if it is different)


#8

I do have changed the sheet name. As you can see in the outline I used the read range twice. Is this a problem?
The first read range activity works smoothly. The second gives me an error message saying that the sheet does not exist.


#9

Can you attach your xaml


#10

Found the solution. One Excel application scope was overwriting the other one.

Thanks for your help @vvaidya & @Lucas.Pimenta


#11

correct… this should not be happen. That error you were getting because Excel scope activity holds that current sheets objects.

Please keep this mind all others for good practice :slight_smile:

Regards…!!
Aksh