How to add multiple excel sheet from other excel files and copy the data and match the name in other excel file?

Hello,

I need some help there that involving in automation on excel in inserting an worksheet and copy the data over
I have added some example below

I would like to add 4 new sheet named A, B, C and D which is optional to my book1.xlsm

i have some excel file name with A , B, C and D(optional) so how can i copy over my excel file to my book1 with the name provided

For A, B, C, D excel file there have some number infront for their unique name while in between they have this unique letter of A, B, C and D will stay there forever
So based on my scenario am come with an automation to copy the data and insert the sheet name ?
Test files.zip (31.1 KB)

@xxGoRpa

You can use copy Sheet activity and copy the sheet from one excel to another

cheers

as currently i have a condition where i cant just copy directly where the name of the other excel contain some keyword = to the sheet i going to paste in
Like say sheet A = 123_A_ABC2023.xlsx etc
Sheet B = 123_B_2023.xlsx

so i cant say i wan copy sheet A to 123_B_ABC2023.xlsx

@xxGoRpa

So you need to find that file which contains A in it then use this

Directory.GetFiles("FolderPath","*_A_*.xlsx")(0)

This will give the file name with A dimilarly you can use variable and get all

Directory.GetFiles("FolderPath","*_"+var+"_*.xlsx")(0)

nice i see can i have an example / sample for UiPath ?

want to try it and what about say optional D as this D excel file sometime is there sometime is not how can i write this as well ?

@xxGoRpa

This is how you would use

first you are checking if atleast one file is matching then get the filename into str_FileName

So for D if its not present then it would give zero files and would go to else side

cheers

so for this do i have to assign a variable first ? erm is it okay you can give me an sample for main.xaml for this so i can try it out tmmr ?

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