Copy particular column rows from excel to another excel

How to copy rows available in “User” column from excel and paste into another excel (.xlsx format)

Input file : HCT_DialoguserList.xls (8.3 KB)

Expected output :
expectedoutput.xlsx (9.7 KB)

Hi @Sathish_Kumar_S

Your query is quite confusing, could you be more specific.


Just want to copy the only the values in “User” column from input file and then paste into a new Excel file?

Please refer expected output file for reference

Hi @Sathish_Kumar_S


Copy Excel Table To Email.zip (190.9 KB)

Hope it helps!!

image

The range is not always fixed… this wont work

May i know the steps to keep only “User” column and remove remaining columns from this excel?

@Sathish_Kumar_S
Remove the range

I am just copying the User column and Pasting it in the other sheet.
Do you want to do the manipulations in the same sheet

Hi @Sathish_Kumar_S

Follow the below steps by using excel activities,
→ Use the Excel process scope activity and insert the Use excel file activity and give the path of the Input file.
→ Inside Use excel file activity insert the Read Range activity to read the excel and store in a datatable called Input_dt.
→ In the Range field in the Read Range activity give the below expression,

Excel.Sheet("HCT_DialoguserList").Range("B25:B"+Excel.Sheet("HCT_DialoguserList").DataTableValue.Rows.Count.ToString)

→ Then use the assign activity to remove the empty rows and store in the same datatable.

- Assign -> Input_dt = Input_dt.AsEnumerable().Where(Function(row) Not(String.IsNullOrEmpty(row(0).ToString()) AndAlso String.IsNullOrWhiteSpace(row(0).ToString()))).CopyToDataTable()

→ After assign activity insert the Use excel file activity and give the new file path where to create. It will automatically create the new file and check the Create if not exists option in the Use excel file activity.
→ Inside Second Use excel file activity Insert the Write datatable to excel activity.

Check the below workflow for better understanding,
Expressions_Practice.xaml (20.6 KB)

Output excel file,
expectedoutput.xlsx (9.0 KB)

Hope it helps!!

1 Like

Thank you…

This works when we want to copy only one column values :

Excel.Sheet(“HCT_DialoguserList”).Range(“B25:B”+Excel.Sheet(“HCT_DialoguserList”).DataTableValue.Rows.Count.ToString)

Can you provide the activity to copy multiple columns values to another excel?

For example :

I want to copy User group,Valid from,Valid to & Reason for User Lock columns values to another excel

Yes we can do it, but give the proper information which columns to copy and paste… @Sathish_Kumar_S

It’s better to close this loop for this query, open the new one for multiple columns.

Regards,

I have created another post for multiple columns. please review it

1 Like

I’ll look into it. Make my post Mark as solution to close this loop… @Sathish_Kumar_S

Regards,