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


#1

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?


#2

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

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


#4

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…!!


How to copy data from one excel sheet to different excel sheet in same workbook
#5

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:


#6

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.


#7

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)