How to copy and paste specified sheets into new workbook?

Current activities in place:

  1. Get workbook sheets
  2. For Each Activity: For each sheet in Allsheets
  3. Read Range Activity: sheet.ToString

Struck at step 4: how to continue with step 4?
The required condition: eg: only sheet1, sheet2, sheet3 to paste into new workbook.

1 Like

Hi @lingmui

Not sure if I understood it correctly, So now you are struck at writing it into new sheet?

If it so then use output of readrange ( of type datatable) and write that into write range activity

Let me know if you have queries


Hi @lingmui

Please refer the xaml below.

Main.xaml (23.3 KB)


(idx+1) <=3 only to applicable to copy sheet in sequence. How to do it if the sheet is random?
Eg: to take those idx in (1, 2, 3, 4 ,5 10, 11, 15)?

Hi @lingmui

Please make array variable that contains the Sheets you want

Loop through the array of sheets variable

With in Loop the Sheets of your Input Excel.

If the ArraySheets.Equals(yourInputExcelsheet)

Then use copy sheet.


Hi @lingmui ,

You can use below test file.
Just place if condition in loop which sheet you want it in destination file.

Let me know if you face any issue.

test.xaml (7.0 KB)

1 Like

Placed if condition:

Copy Sheet.

But the bot is not able to copy the selected sheet.

Hi @lingmui ,

Can you share the screenshot of it, how exactly you are doing it ?

Parent Excel Path.xlsx (28.6 KB)

Hi @lingmui ,

The file you have shared is the file where i have to pace data or this is the file from where i have get data and place it in another workbook.

Please clarify.

Parent Excel Path.xlsx (62.1 KB)

The file is the one in excel application scope: File ->workbook path

Can you try now?

test.xaml (10.9 KB)

Please make sure no output file present, it will create file automatically

Let me know if you have any concern.

thanks for the file. the xaml is working.

1 Like

nice :slightly_smiling_face:

any reason why condition : Eachsheet.Equals(“AA”,“XX”) is not working?

But it’s work for condition:
Eachsheet = “AA” or Eachsheet =“XX”

you can use either.

using test.xaml , with condition Eachsheet.Equals(“AA”,“XX”) it’s not working.

i have not tried with Eachsheet.Equals(“AA”,“XX”)
Better to use or condition.

Basically it used to compare string.
Check this

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