Hi
I am new to UiPath. For the range in “Write Cell”, I want to refer to the column number instead of its letter. I tried the below, but it gives back the error that “Range does not exist”.
“Columns(7)”+ Counter.ToString
Hi
I am new to UiPath. For the range in “Write Cell”, I want to refer to the column number instead of its letter. I tried the below, but it gives back the error that “Range does not exist”.
“Columns(7)”+ Counter.ToString
@Anonymous2 I guess the range in Write Cell or Write Range can only have the inputs that are in Excel, That are Alphabets and Numbers Combined. Hence it gives out the error
May I know why you are trying with Column Index ? Is there any particular reason to do like this ?
Hi
Thank you for the reply. I will be using it in a For loop where the number of the column is represented by a counter that increases.
Thank you
@Anonymous2
When you are referring an excel cell, there are two pointers involved. 1) Row index & 2) Column index
For example, If you have to write into the first cell, it will be referred as A1. i.e., A Column & 1st Row.
When you are using a counter to increment the row index, specify as
var rowIndex = ‘A’
for(var colIndex = 1; colIndex < 10; colIndex++)
{
writeCell(rowIndex+colIndex.Tostring);
}
If you want the column index to be incremented,
First store the alphabets in an array. (Max columns)
rowArray = {‘A’,‘B’,‘C’,…,‘X’,‘Y’,‘Z’}
Now refer the index of array to get the rowIndex
var columnIndex = 1
for(var rowIndex = 1; rowIndex < 10; rowIndex++)
{
writeCell(rowArray(rowIndex-1)+colIndex.Tostring);
}
Note: rowArray(rowIndex-1) because the the first index of the array will be 0
If you need to use both row and column increments, then use the combination.
Hope this is helpful!