Hi All,
I use a For Each Row to build a DataTable
In the For Each Row Sequence i have a If activities
If there is a certain condition i would like to write cell with a “text”
Else i would like to write cell with another “text”
In the If:
i use write cell and set the range as “A” + Counter.ToString
and outside the If, i add Counter = Counter + 1
but this only means that it will always write in A3
How do i write the logic so that it will write in the IF sequence as such
Then: write in A2
Else: write in A2
in the next loop
Then: write in A3
Else: write in A3
in the next loop
Then: write in A4
Else: write in A4
so on and so forth till the excel next line item is a blank
Hi @minthodology
If you provide the Excel file for the same and if you explain more in detail then it will be easy to give you the solution
Happy Automation
Best Regards
Er Pratik Wavhal
Hi Pratik,
Excel example as follows:
In this case, i would like to write into the Cell C2, C3, C4
Srini84
(Srinivas Kadamati)
August 29, 2020, 8:38am
5
@minthodology
In If Condition, You have to give as
row("ColumnName") = isInRecord
Mark as solution if this helps you
Thanks
Hi,
There is an error saying Option Strict on disallows operands of type Object for operator ‘=’ . Use ‘is’ operator to test for object identity.
Srini84
(Srinivas Kadamati)
August 29, 2020, 8:46am
7
@minthodology
Oops sorry
row("ColumnName").ToString = isInRecord
Check as above
You can check below post for your reference too
Thanks
Srini84
(Srinivas Kadamati)
August 29, 2020, 8:51am
8
@minthodology
What’s the condition you are checking for? What is isInRecord value holds?
Thanks
It holds a Element Exist which is a Boolean
Hi, thanks
now the new error is Option Strict on disallows implicit conversions from 'Strings to ‘boolean’
my isinrecord is a boolean
Srini84
(Srinivas Kadamati)
August 29, 2020, 8:58am
11
@minthodology
Can you share your workflow? I didn’t see Element Exist inside the For Each Row? then you will get for element exist for the first row only
Also instead of Counter, you can use Index of the For each to increment
Hope this may helps
Thanks
Hi,
It is inside the For Each Row before the If activity
Srini84
(Srinivas Kadamati)
August 29, 2020, 9:06am
13
@minthodology
Fine, Then you can use Index variable as below for increment
Create a Index variable, and remove Counter.ToString and place Index.ToString
Hope this helps you
Thanks
how do i create a index variable?
Srini84
(Srinivas Kadamati)
August 29, 2020, 9:09am
15
@minthodology
Just create a variable in index
OR
You can use the counter variable to that index
Thanks
Srini84
(Srinivas Kadamati)
August 29, 2020, 9:10am
17
@minthodology
Yes, any with variable type Int32, You can use your existing counter variable also
Thanks
Now the error is the Write Cell: The range does not exist
Srini84
(Srinivas Kadamati)
August 29, 2020, 10:07am
20
@minthodology
write as below
"C" + (Counter + 2).ToString
Mark as solution if this helps
Thanks