How to copy selected columns from one excel file to another

Hello Guys,

I have an xlsx file with 7 columns, and I would like to copy 3 of the columns (including headers)to a newly created file. However, I’ve been having problems with “Write Range”.

SourceFile Path: C:\Users\lekan\Desktop\SourceFile.xlsx
DestinationFile Path: C:\Users\lekan\Desktop\DestinationFile.xlsx

Columns to copy are: Customer ID, Customer Country, Phone Number, Quantity

Thanks a lot guys!

Hello ,

Use the Read Range activity to pass the values into datatable and delete the columns that you do not need using DataTable.Columns.Remove(“columnName”) and then use Write Range activity to the excel file that you want fill.

Or
Use the Read Range activity to pass the values into datatable use for each row activity to add the values by columns to another datatable and then write it into the other excel file.

1 Like

Hello,

Please find the attached workflow. Kindly check and let me if you face any issues.

With Thanks,
NagiDemo.zip (27.2 KB)

1 Like

Can you send the sample excel file ? @dmitroika1

Hi @dmitroika1

1.Use Read Range Activity and create output data table variable(DT).
2.Use this syntax for selecting specific columns use assign activity DT1=DT.Select().CopyToDataTable.DefaultView.ToTable(True,“Customer ID”, “Customer Country”, “Phone Number”, “Quantity”)
3.Use Write Range Activity check add headers in properties pass the data table variable.

Regards,
Kommi Jeevan.

Regards

1 Like

Thanks nagireddy18,

It works perfectly!

And thanks to everyone for your contributions.

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