VBA – Copy worksheets from another open workbook to default workbook

The sourceworkbook name changes, but the sheet names inside the workbook remain the same. 

 

Private Sub CommandButton1_Click()

 

Dim sourceworkbook As Workbook

Dim currentworkbook As Workbook

 

For Each sourceworkbook In Application.Workbooks

If sourceworkbook.Name Like “Summary_Bsln_Curb.xlsm” Then sourceworkbook.Activate

Next sourceworkbook

 

Set currentworkbook = ThisWorkbook

 

sourceworkbook.Sheets(“MSRoll”).Copy after:=currentworkbook.Sheets(“Revisions”)

 

Set sourceworkbook = Nothing

Set currentworkbook = Nothing

 

ThisWorkbook.Activate

Worksheets(“Macros”).Activate

Worksheets(“Macros”).Range(“A1”).Select

 

End Sub

By: Jasjot Kaur

11 thoughts on “VBA – Copy worksheets from another open workbook to default workbook

  1. ig

    Heya just wanted to give you a quick heads up and
    let you know a few of the images aren’t loading correctly.
    I’m not sure why but I think its a linking issue. I’ve tried it in two different internet
    browsers and both show the same results.

  2. www.ua.all.biz

    It’s a pity you don’t have a donate button! I’d without a doubt
    donate to this fantastic blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account.
    I look forward to new updates and will talk about this
    site with my Facebook group. Talk soon!

Comments are closed.