How the read a specific row in excel and copy it into another excel file

Hello Community-guys,

i need some help i think, because i didn’t find a solution until now.

What i want is, when the robot reads an excel file, he should stop at a specific row, copy all the row items (for example all the values from A5 - T5) and paste this row under the headline of a new excel file sheet.

How did i do it until now:
Inside an Excel Application scope, i read the hole sheet. When the robot is at the 5th row/line, he should copy the row. I have created a second read range inside the “for each row”-activity. My idea is, to copy the range A5-T5 into another datatable and put the values with the “write range”-activity into another Excel-File, BUT only when the specific rows/lines are read. In that case, i have a second Excel-Application Scope inside the for each row, with the write range.

Here is a screenshot. The Read-Range in the if is ““A” + DBTransaktionsjournal.Rows.IndexOf(row).ToString + “;T” + DBTransaktionsjournal.Rows.IndexOf(row).ToString”

But i always become the error-massage: Read Range: Object reference not set to an instance of an object. I don’t know why. My brain has stopped.

I don’t know if my way is the best/efficient way. What i don’t what is, to assign all the values to a variable and write it. There must be a simpler and better solution.

Thanks in advance for the replies and helps.

1 Like

Hi, Kibar!

Please, try replacing the semicolon with a colon

“A1:A2”

1 Like

Hi @kibar.albayoglu

Have a view on the below tutorial link below!

Regards

1 Like

Hi @kibar.albayoglu,

If you have a fixed number till which row you want to read like reading till 6. 7 etc row then you can do like below -

dt_TransactionData.AsEnumerable().Take(5).CopyToDataTable

5-> integer value count till the rows required.

use this in a assign and then append/write the resulting DT in the other file.

Thanks

1 Like

Hi Sergey,

thanks for your reply. I chaned it, but i have had the same error message.

Nevertheless, it was a simple little mistake. Thank you for bringing this to my attention.

1 Like

Hi Pravin_calvin,

thank you.

The tutorial doesn’t show how to copy paste it with the excel-application scope.

But after all, it works fine. Only the value Format of Date and time is not correct. Do you know why and how to fix that?

Thanks :wink:

1 Like

Hi Shikhar,

thank you very much. I noticed your advice.

In my case, i have not a fixed number, where the bot have to copy the row.

You are welcome!) Please click the “solution” button if the error is resolved)

image

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