Write cell for every row while looping (for each row)

HI there, I tried to copy every row in a excel, open the browser and copy a certain email back in the same excel and different cell.
It works fine until the “write in cell” - it always writes in the same cell and overwrites the result.
I guess it is because of the loop - i tried a lot of different stuff but nothing works.
can you plz help me ??

oh i cant upload anything…

Thx Daniel

@Daniel32,

In For Each Row, first find the index of the row like this: dataTableName.rows.indexOf(row)+2 and store result in interger variable say ‘index’.

In write cell, pass Range like this:

If you want to write in ‘D’ Column then pass range as: “D”+index.Tostring

3 Likes

it is a pitty that i can not upload anything … which activity should i use for indexing the row

@Daniel32

Inside For Each Row activity, take one Assign activity.

Index = dataTableName.rows.indexOf(row)+2

Here, Index is of type interger variable.

1 Like

Maybe you can have a look:
https://drive.google.com/file/d/1y0UNHmwVv7qEoUimRrImCwxr2OFUrTRi/view?usp=sharing

Hello @Daniel32,

Hope this could help you :slight_smile:

Check your code, you are always writting the clipboard value in cell C2.

image

You can use a variable to increase the value of the cell, something similar to the this:

Thanks and best regards,
Susana

9 Likes

Hi,

thank you for your help.

It is a pitty but it doesn’t work.

It gets stuck in the second excel.

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:

UiPath.Excel.ExcelException: Exception from HRESULT: 0x800AC472 ----> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800AC472

at Microsoft.Office.Interop.Excel._Worksheet.Activate()

at UiPath.Excel.WorkbookApplication.SetSheet(String sheetName, Boolean createNew)

— End of inner ExceptionDetail stack trace —

at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)

at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)

at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Greetings

Daniel

Just try it again, and dont intervene in excel that is open. Could be possible that the excel may have been open or in use by you so the accees by the bot failed.

sorry but it still writees in the same cell…
it doesnt take the next cell.

I guess it is because of the start sequence where i open each Url in the excel.
Without showing you pictures or my data it is nearly impossible to explain it. What can i do to upload pictures in the forum?

Thx
Daniel

1 Like

its fine, new users cannot upload.
so now, your next cell logic isint working. did u use the solution provided by Susana.
It should work if you have initialized and incremented in the correct place.

Try to debug and see if you can understand how the logic is flowing and as to why the index is not getting used.

Yes the solution from susan does not work.
It is difficult to explain as a Noobie in words what is actually not working.
This is the debug protocol - maybe it helps u to understand me - this would be great:

“Write cell executing”
{
“message”: “Write Cell Executing”,
“level”: “Trace”,
“logType”: “Default”,
“timeStamp”: “16:41:23”,
“processVersion”: “1.0.6715.21390”,
“jobId”: “92b94003-4fce-4035-937b-024a302929dc”,
“robotName”: “DANIEL”,
“machineId”: 0,
“fileName”: “Main_190409.2”,
“activityInfo”: {
“Activity”: “UiPath.Excel.Activities.ExcelWriteCell”,
“DisplayName”: “Write Cell”,
“State”: “Executing”,
“Variables”: {
“variable2”: “”,
“position”: “”,
“variable3”: “”,
“variable4”: “”,
“dt2”: “”,
“dtout”: “”,
“clipboardout”: "
“dtrange”: “”,
“Counter”: “”,
“Dt_ExcelData”: “”,
“index”: “2”,
“row”: “System.Data.DataRow”,
“session”: “”,
“chrome”: “UiPath.Core.Browser”,
“Email”: “”,
“foreachrowoutput”: “0”,
“dt”: “”,
“url”: “url”,
“uname”: “”,
“pwd”: “”,
“datarow”: “”
},
“Arguments”: {
“Cell”: “C2”,
“Text”: "
“SheetName”: “Tabelle1”
}
}
}

ASSIGN
Assign Executing
{
“message”: “Assign Executing”,
“level”: “Trace”,
“logType”: “Default”,
“timeStamp”: “16:41:23”,
“processVersion”: “1.0.6715.21390”,
“jobId”: “92b94003-4fce-4035-937b-024a302929dc”,
“robotName”: “DANIEL”,
“machineId”: 0,
“fileName”: “Main_190409.2”,
“activityInfo”: {
“Activity”: “System.Activities.Statements.Assign”,
“DisplayName”: “Assign”,
“State”: “Executing”,
“Variables”: {
“variable2”: “”,
“position”: “”,
“variable3”: “”,
“variable4”: “”,
“dt2”: “”,
“dtout”: “”,
“clipboardout”: “url”,
“dtrange”: “”,
“Counter”: “”,
“Dt_ExcelData”: “”,
“index”: “3”,
“row”: “System.Data.DataRow”,
“session”: “”,
“chrome”: “UiPath.Core.Browser”,
“Email”: “”,
“foreachrowoutput”: “0”,
“dt”: “”,
“url”: “url”,
“uname”: “”,
“pwd”: “”,
“datarow”: “”
},
“Arguments”: {
“Value”: “3”
}
}
}

Hi Susana,

Thanks a lot this helps.

:slight_smile: