Moving a sheet from one excel to another excel


#1

Hi – I want to move one sheet from a excel file to another file. I use 2 excel application scope – One for read range and another for write range. It executes successfully, but i am not getting the same format from the original file. It is pasting as values and need the same format to the 2nd file. Can you help me on how to move the sheet to another?


#2

@Subram As read range stores the data in Datatable, you cannot maintain the same format of the excel file. You follow below steps in order to delete a sheet from excel:

  1. Make a copy of the original file by copying the file to some path.
  2. Delete the sheet by using Ui-Automation on the excel.
    – as you would already know the sheet name which needs to be deleted, use “Ctrl+g” hotkey on the excel file to go to the sheet.
    – type “Sheetname!A1” in the “Go To” Window (which comes after you hit "Ctrl+g)
    – Click on Home-> Delete->Delete Sheet. (Please find attached screenshot for this).

#3

Thanks for your response :slight_smile: But still i am not able understand . I already created a folder in a path and have 2 files in the folder. All i want is i want to move one particular sheet from file one and insert with same format in file two. Sorry if you have already answered this, but still if you can explain further it would be great


#4

Hello @Subram,

can you just execute below code if it suites your match then merge it?
Main.xaml (14.2 KB)
Report.xlsx (8.7 KB)

Thanks,
Pankaj


#5

Getting this error. I have saved the file in my computer and executed it


#6

Hello @Subram,

could you please send/attach an error that will be shown on console in read color?

Thanks,
Pankaj


#7

here you go


#8

Could not find member ‘CreateNewFile’ in type ‘http://schemas.uipath.com/workflow/activities:ExcelApplicationScope’. Row: 72, Column: 57


#9

Hi @Subram,

You want to move excel sheet from one sheet to another sheet or
one excel file file to another excel file


#10

I want to move One sheet from Excel file A to another sheet In Excel file B


#11

Hi @Subram,

kk
Please find the attachment of solution

Its easymove from one file to another file.xaml (7.4 KB)


#12

Thanks – This is easy and i know this :slight_smile: My question is i need the same format from the original sheet. but this query paste special values

I have attached the screen shot of the format. but while pasting the colour goes off

image


#13

Hi @Subram,

using copy file activity we can get that
chk it once
I got the file exactly with color


#14

Copy file will copy the whole file, but i need to copy only the sheet.Eg total 3 sheets in a file and i need to copy only one sheet amd move to a difference excel file


#15

Hi @Subram

May be a macro can solve the problem,such like :

Sub MacroCopySheet()

    Sheets([target sheet]).Select
    Sheets([target sheet]).Copy Before:=Workbooks([destination workbook]).Sheets(1)

End Sub

You can try this,and let me know if it works.

Regards.


#16

Hi @lainh,

yes its good idea
We can do using macros


#17

you are experts :slight_smile: but i am not!!! Please send me an excel file with a macro and i can edit the sheet name. plssssssssssssss


#18

Hi @Subram

Please check the attachment file.
I upload one set of the sample:
1.the xaml (to use it you should rewrite the [excel.exe]'s and the excel files’s path)
2.the target excel
3.the destination excel

CopyExcelSheet.zip (20.2 KB)

Please try it.


#19

What action u used in the below? its not appearing

image


#20

Also tell me the macro name – i think you used execute macro