For each row in Column A Insert Some Value

Hi all,

I have an excel that outputs as attached.

InsertValueForEachCell_In_ColumnC_Updated.xlsx (10.0 KB)

Is there a way to insert a text string for example, = “200” in column A for each row in Column B that has some data?

The datatable would start from A10 to C109.
The number of rows output is dynamic.
This would mean row 109 = last row is dynamic.

Thanks in advance


1 Like


Welcome to uipath forum

Hope the below steps would help resolve this

  1. Use a excel application scope and pass filepath as input and use a read range activity and get the output as dt

  2. Now use a FOR EACH ROW activity and pass dt as input

  3. Inside the loop use a IF activity with a condition like this

NOT String.IsNullOrEmpty(CurrentRow(“ID”).ToString.Trim)

If true it goes to then block where use a assign activity like this

CurrentRow(“Status”) = “100”

Note : if you want append 100 to the existing value in column B then mention like this in assign activity

CurrentRow(“Status”) = “100” + CurrentRow(“Status”).ToString.Trim

This can handle any dynamic number of rows

Cheers @Md_Hidayat

1 Like

Thank you for the solution!
It works but I decided to go against using it in production due to the concern of this performance. By using If Else to write lines it took me around 5mins, due to the number of records in needs to go through.

Here is what I did instead.

As my output table is generated from PowerQuery, I build an additional Custom Column in PowerQuery where [Status] = 100.

Once the output table is generated I created an assignment in UIpath for Status.

Assignment_Status =
ColumnAlltable.DefaultView.ToTable(false, ColumnAlltable.Columns(“Status”).ColumnName )

Once the assignment is created, I simply use ExcelWriteRange to do a paste operation from “A10”, where column = Status

Total time for this alternative solution less than 10 secs.

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