Copy Worksheets into already existing Workbooks with VBA

mrsleepy95

New Member
Joined
Feb 5, 2018
Messages
4
I have a Workbook that has 10 different Worksheets in it, all with their individual names. Then I have 10 separate Workbooks, all with names corresponding to the Worksheets names. I am looking to copy each worksheet in the original Workbook into its relative individual workbook.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
What is the full path to the folder containing the separate workbooks? Are the ten files the only files in that folder? Can you list 3 or 4 worksheet names with their corresponding workbook names including their extension (xls, xlsx, xlsm)?
 
Upvote 0
What is the full path to the folder containing the separate workbooks? Are the ten files the only files in that folder? Can you list 3 or 4 worksheet names with their corresponding workbook names including their extension (xls, xlsx, xlsm)?

The full path to the folder containing the separate workbooks is F:\Master Workbooks\Calgary Change Variables 1971-2006\Prop

I used 10 files as an example, but there are actually files in that folder. A few examples of the worksheet names are "HH Gross Rent 30 Perc Inc LQ", "HH Owners Pay 30 Perc Inc LQ", and Avg HH Inc LQ". Their corresponding workbook names are exactly the same. The extensions are .xlsb.
 
Upvote 0
The full path to the folder containing the separate workbooks is F:\Master Workbooks\Calgary Change Variables 1971-2006\Prop

I used 10 files as an example, but there are actually files in that folder. A few examples of the worksheet names are "HH Gross Rent 30 Perc Inc LQ", "HH Owners Pay 30 Perc Inc LQ", and Avg HH Inc LQ". Their corresponding workbook names are exactly the same. The extensions are .xlsb.

Sorry, I meant that there are 69 files in that folder.
 
Upvote 0
Try:
Code:
Sub CopySheet()
    Application.ScreenUpdating = False
    Dim wkbDest As Workbook
    Dim wkbSource As Workbook
    Set wkbSource = ThisWorkbook
    Dim ws As Worksheet
    For Each ws In wkbSource.Sheets
        Set wkbDest = Workbooks.Open("F:\Master Workbooks\Calgary Change Variables 1971-2006\Prop\" & ws.Name & ".xlsb")
        ws.Copy after:=Sheets(Sheets.Count)
        wkbDest.Close True
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Try:
Code:
Sub CopySheet()
    Application.ScreenUpdating = False
    Dim wkbDest As Workbook
    Dim wkbSource As Workbook
    Set wkbSource = ThisWorkbook
    Dim ws As Worksheet
    For Each ws In wkbSource.Sheets
        Set wkbDest = Workbooks.Open("F:\Master Workbooks\Calgary Change Variables 1971-2006\Prop\" & ws.Name & ".xlsb")
        ws.Copy after:=Sheets(Sheets.Count)
        wkbDest.Close True
    Next ws
    Application.ScreenUpdating = True
End Sub

This worked perfectly, thank you so much!
 
Upvote 0
Cross posted https://www.excelforum.com/excel-pr...into-already-existing-workbooks-with-vba.html

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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