ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to merge open workbooks (https://www.excelbanter.com/excel-programming/371258-macro-merge-open-workbooks.html)

Barry McConnell

Macro to merge open workbooks
 
Is there a small macro that will take all the worksheets from all open
workbooks and put them in one new consolidated workbook?

Thanks

Barry


Tom Ogilvy

Macro to merge open workbooks
 
Sub CopySheets()
Dim bk As Workbook, bk1 As Workbook
Set bk = Workbooks.Add()
For Each bk1 In Application.Workbooks
If bk1.Windows(1).Visible Then
Application.DisplayAlerts = False
bk1.Worksheets.Copy After:=bk.Worksheets(bk.Worksheets.Count)
Application.DisplayAlerts = True
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"Barry McConnell" wrote:

Is there a small macro that will take all the worksheets from all open
workbooks and put them in one new consolidated workbook?

Thanks

Barry



All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com