Copy data columns from one sheet to new sheet in the same workbook

Hi; I have an Excel sheet has data from column A to R. I want to copy columns A,D,F,H & R to a new sheet within the same workbook. How can i do that?

1 Like

Hi, one solution can be to read all the data to datatable, remove all the columns you dont want and then write the data from data table to the new sheet (it will be created automatically with WriteRange activity if the sheet doesnt exist yet)

3 Likes

Hello @joo77uip,
You can try this using Query(SQL Query) also. Use connect to database and pass sql query to read data from excel file. In the query you have to mention the fields which you want to fetch, so that you can fetch the required fields. Otherwise read using “Select * from [$Sheet1]” and store the required columns in variables (By Column Names) and add them into new datatable. Write that data table to a new sheet using write range activity by providing the new sheet name in write range activity.
Hope it helpes. :slight_smile:
Jiban

2 Likes

Hi @joo77uip

Hi You can simply read the data of Sheet1 by using Read range activity and use its datatable output and use write range activity with "Sheet2" name.

You can find following attached solution for further help.

Let me know if any further information you wants on this.

copysheetSolution.zip (8.1 KB)

Regards…!!

4 Likes

Hi @joo77uip,
In other way if you want to just copy and paste then you can try using shortcut keys to select the range of data you want to copy and set them to clipboard. Switch to the other excel sheet and paste using shortcut keys and save the file. Its not the feasible way but as you have started the issue named “Copy data from columns from one sheet to new sheet”. It totally matches as per your subject line. :grin:

2 Likes

I like your idea but how to set the properties for remove column Q activity… I don’t understand how i set the values for column, columnName or columnIndex.

1 Like

if you have headers (you can check this option when reading the range) you can use either from two options, if you dont have headers just use column index (note that you have to remove columns from the last one, otherwise the indexes will be changing e.g. you remove 2nd column and 3rd column will become 2nd in the table and so on)

1 Like