How to merge sheets in two workbooks through vba gives code example

You can use VBA's Workbook.Union method to merge sheets in two workbooks: Sub MergeSheets()Dim wb1 As Workbook, wb2 As WorkbookDim sht As Worksheet, unionRng As RangeSet wb1 = Workbooks.Open("C:\Book1. xlsx")Set wb2 = Workbooks.Open("C:\Book2.xlsx")For Each sht In wb2.WorksheetsSet unionRng = Union(wb1.Sheets("Sheet1"), sht)Next sh

Guess you like

Origin blog.csdn.net/weixin_42577735/article/details/129617367