# Merging multiple excel fiels into multiple sheet of an excel

**URL:** <https://forums.powershell.org/t/merging-multiple-excel-fiels-into-multiple-sheet-of-an-excel/237>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/merging-multiple-excel-fiels-into-multiple-sheet-of-an-excel/237 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/merging-multiple-excel-fiels-into-multiple-sheet-of-an-excel/237/1 "2011-12-31T18:30:00Z")

</div>

by naveenjv at 2012-10-09 06:50:35

> **Hi,**  
>   
> **I have two two different excel files with one sheet each (with formated columns). How do I merge these two excel files into different sheets of a single excel using powershell**  
>   
> **Please help.**  
>   
> **Thanks,  
> Naveen J V**

by JeffH at 2012-10-09 08:33:43

> Is this a one-off task or something you need to do on a repeated basis or for a lot of files? You could use PowerShell to read the files and write data to a new file. I might try running through the process manually and record a VBA macro. You can use the macro as a guide in developing a PowerShell script. You’ll need to use the Excel.Application COM object. This is not going to be a simple project.

by naveenjv at 2012-10-09 21:59:31

> Hi Jeffery Hicks,  
>   
> I would like to create a script which works in a general way.   
> For example, if I have three excel files, I would like to combine all three files into one excel file with three different sheets.  
> I would like to accomplish this using PowerShell.   
> Can you please guide?  
>   
> Thanks,  
> Naveen J V

by JeffH at 2012-10-10 06:38:49

> See if this gets you started.  
>   
> `$excel = New-Object -ComObject "Excel.Application"$wb = $excel.Workbooks.Add()$file = $excel.workbooks.open("C:\work\files.xlsx")$file.Sheets.item("files").Select()$file.Sheets.item("files").Copy($wb.sheets.item("Sheet1"))#don’t save any changes to this file$excel.DisplayAlerts=$False$file.close()$excel.Visible=$True`  
>   
> You might also want to take a look at [http://jdhitsolutions.com/blog/2012/05/ … and-demos/](http://jdhitsolutions.com/blog/2012/05/san-diego-2012-powershell-deep-dive-slides-and-demos/)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:03pm UTC](https://forums.powershell.org/t/merging-multiple-excel-fiels-into-multiple-sheet-of-an-excel/237/2 "2024-05-16T21:03:52Z")

</div>


