How to merge excel files into 1 file and to name sheet according to file name?

navnav21

New Member
Joined
Jun 2, 2021
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi I have 100 excel files and i want to merge all these files into 1 excel file with all 100 sheets. I also want to rename the sheet the same as the file name. in some excel files, they have 2 sheets. For example, Feb 2021 has 2 sheets and i want to rename them "Feb 2021 (1)" and "Feb 2021 (2)".

Can someone help create this VBA code please?

Thank you in advance!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Would not be easier to simply append all 100 of them with sheet name in a column??

this is very easy do able in powerquery.

here are some sample files (Book 3,4,5)
and my test query,


test file:
 
Upvote 0
Would not be easier to simply append all 100 of them with sheet name in a column??

this is very easy do able in powerquery.

here are some sample files (Book 3,4,5)
and my test query,


test file:
Hi Thanks for this, but the output is all into 1 sheet. I need them still in different sheets.

For example, i have 10 different excel files, each have 1 sheet each. i need to all these 10 sheets into 1 excel file. and for each sheet i need to rename them according to their respective file name

Currently I am running 2 VBA codes:

1624522473354.png


This merges the all the sheets into 1 excel file.

The other VBA code is to rename the sheets.

Thank you!
 
Upvote 0
Thats what ull get in the last column - file name from which the data came from.

so if u merge 3 files (excelworkbooks) named A, B, C
ull get last column A, B, C respectivly

And now you can use ExcelMacroMastery advanced filter VBA solution to split this by criteria.
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top