Vba to combine Worksheets from 2 different workbooks:

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I need help with Vba to combine Worksheets from 2 different workbooks:
From Book1.xlsm, i need sheets("Data") and sheets("Summary")
Summary sheet has formulas calculated using Data sheet.
Likewise from Book2.xlsm i need sheets("Daily Expenses") and sheets("Daily Incomes") and sheets("T_Summary")
I want to club this 5 worksheets by creating new workbook called CombinedWb.xlsm.


Thanks in advance for helping!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Can someone please help me with this?:(
maybe a link...or a code:)

Thanks again and sorry for bumping!
 
Upvote 0
Try something like this...

Code:
[font=Verdana][color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] CombineWorkbooks()

    [color=darkblue]Dim[/color] wkbDest [color=darkblue]As[/color] Workbook
    [color=darkblue]Dim[/color] wkbBook1 [color=darkblue]As[/color] Workbook
    [color=darkblue]Dim[/color] wkbBook2 [color=darkblue]As[/color] Workbook
    
    Application.ScreenUpdating = [color=darkblue]False[/color]
    
    [color=darkblue]Set[/color] wkbDest = Workbooks.Add(xlWBATWorksheet)
    
    [color=darkblue]Set[/color] wkbBook1 = Workbooks("Book1.xlsm")
    [color=darkblue]Set[/color] wkbBook2 = Workbooks("Book2.xlsm")
    
    wkbBook1.Sheets(Array("Data", "Summary")).Copy after:=wkbDest.Worksheets(wkbDest.Worksheets.Count)
    
    wkbBook2.Sheets(Array("Daily Expenses", "Daily Incomes", "T_Summary")).Copy after:=wkbDest.Worksheets(wkbDest.Worksheets.Count)
    
    Application.DisplayAlerts = [color=darkblue]False[/color]
    wkbDest.Worksheets(1).Delete
    Application.DisplayAlerts = [color=darkblue]True[/color]
    
    Application.ScreenUpdating = [color=darkblue]True[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[/font]
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,245
Members
452,900
Latest member
LisaGo

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