How to copy the data from excel sheet specific columns and add into another excel sheet

How to copy the data from excel sheet/file specific columns and add into another excel sheet/file.

Suppose i have excel sheet 1, i want to copy the data from Column B and Column D.
And then i want to add/paste into the another sheet, e.g. sheet 2 which also having the same structure data.

Can anyone suggest how to do it?

@vaibhav2.chavan,

You can use a “read range activity” to read from the first file and then use a “write range activity” to write on the second file, otherwise to copy from one sheet to another, checkout the below activity.

@SenzoD - But i want to copy the column data of B and D column not the C column. so how to handle this?

@vaibhav2.chavan You can use Read Range to read the Excel File and get output as Datatable and then you can use the Filter Datatable Activity and Specify the Columns you need in the Output Columns Section of the Filter Wizard, and then the Resultant Output Datatabe of Filter Datatable Activity is the Result with Only the Columns you need. Then you can use that Output Datatable to write it to a Different Excel File using Write Range Activity.

Try this and let me know. Also Specify Header names not the Range names (A,B,…)

1 Like

@vaibhav2.chavan,

So use a read range activity to read from the file
use a filter DataTable activity to only filter for the columns you want and then use write range activity to write the data from filtered DataTable

make sure you click on the Output Columns
Make sure the keep radio button is checked
also make sure the column names are exactly the same as the one from the file you are reading from, and then wrap the column names inside the: " "

See example, The columns you type in are the ones you want, if the “Keep” button is checked

@vaibhav2.chavan
As far as I understood your requirements you are interested on col B And D. But the result should have the same strucutre e.g Col A-F

as an alternate approach give a try on

  • Assign Activity
    Left side: dtFiltered - DataType: DataTable
    Right side: YourDataTableVar.Clone

  • Assign Activity
    Left side: dtFiltered
    Right side:

(From d In YourDataTableVar.AsEnumerable
Let ra = {Nothing, d(1), Nothing, d(2), Nothing, Nothing}
Select dtFiltered.Rows.Add(ra)).CopyToDataTable

Within the write Range Range is A1. As the structure is kept, taken from origin Datatable only ColB and ColD will be filled with the retrieved values

1 Like

@supermanPunch/@SenzoD

I’m able to do till the filter data but what to mention in Range? as i have write in Column B and Column D within “Sheet1” which is another sheet.

image

Hi @vaibhav2.chavan,

You can user ReadRange activity and specify the Range name and store the data Table, now using For Each activity you can get the data which columns you want.
image