'Copy the used range of the second worksheet to the destination range in the first worksheet 'Specify the destination range in the first worksheetĭim destRange As CellRange = sheet1.Range(sheet1.LastRow + 1, 1) 'Get the used range in the second worksheetĭim sourceRange As CellRange = sheet2.AllocatedRange Save the result file using Workbook.SaveToFile() method.ĭim workbook As Workbook = New Workbook()ĭim sheet1 As Worksheet = workbook.Worksheets(0)ĭim sheet2 As Worksheet = workbook.Worksheets(1).Remove the second worksheet using XlsWorksheet.Remove() method.Copy the used range of the second worksheet to the destination range in the first worksheet using CellRange.Copy(destRange) method.Note the row and column indexes are 1-based. Specify the destination range in the first worksheet using Worksheet.Range property.Get the used range of the second worksheet using Worksheet.AllocatedRange property.Get the two worksheets that need to be merged using Workbook.Worksheets property.
![how to merge workbooks in excel 2013 how to merge workbooks in excel 2013](https://gorilla.bi/wp-content/uploads/2020/06/7-ways-to-open-Multiple-Instances-of-Excel-Featured-Image.png)
Initialize a Workbook object and load an Excel file using Workbook.LoadFromFile() method.
#How to merge workbooks in excel 2013 how to#
The following steps show how to merge two Excel worksheets in the same workbook into a single worksheet: We can merge multiple worksheets in the same or different workbooks into one. Merge Multiple Excel Worksheets into One in C# and VB.NET NewWorkbook.SaveToFile("MergeWorkbooks.xlsx", ExcelVersion.Version2013) 'Copy each worksheet from the current workbook to the new workbook
![how to merge workbooks in excel 2013 how to merge workbooks in excel 2013](https://1.bp.blogspot.com/-ckpJwnOS7x8/X9pcX7D-XbI/AAAAAAAABpo/p6Td04EPZgMp9BIaUiRd1C3Z1hhFKQruwCLcBGAsYHQ/s0/Pic%2B1.jpg)
'Loop through the worksheets in the current workbookįor Each sheet As Worksheet In tempWorkbook.Worksheets 'Initialize another temporary Workbook objectĭim tempWorkbook As Workbook = New Workbook() 'Create a string array from Excel file pathsĭim inputFiles = New String() ĭim newWorkbook As Workbook = New Workbook() Private Shared Sub Main(ByVal args As String())