Vba copy tabs into an existing workbook

ccg4051

New Member
Joined
May 8, 2018
Messages
1
hi all,

So my question is, I have and two tabs ("Materials" and "Delivery") I would like to import into and existing workbook we use for quotations. the tab "Materials" work perfectly under the code below:

Private Sub CommandButton1_Click()
'Read Data
Dim wsname As String
Dim hours As Integer
hours = Range("h65")
wsname = ActiveWorkbook.Name
'Worksheets("Materials").Visible = False

'Open Workbook
Workbooks.Open "\\TWS-VS1061\Template\IBMS\HQ FORMS\300 - Commercial\HQ 304 Estimate Summary (2018 Rates).XLSM"
'Change Dir.
ChDir "\\TWS-VS1061\Template\IBMS\HQ FORMS\300 - Commercial"
'Write Data
'Workbooks("Quotation Mk1.xlsm").Sheets("Materials").Copy Before:=Workbooks("HQ 304 Estimate Summary (2018 Rates).XLSM").Sheets(6)
Workbooks(wsname).Sheets("Materials").Copy Before:=Workbooks("HQ 304 Estimate Summary (2018 Rates).XLSM").Sheets(6)
Worksheets("BudgetSummary").Activate
Worksheets("BudgetSummary").Range("C12").Value = 11
Worksheets("BudgetSummary").Range("N25").Value = "=Materials!H65+AF32"
Worksheets("BudgetSummary").Range("E41").Value = "=Materials!I65"
'Worksheets("Materials").Visible = True
Worksheets("materials").PageSetup.PrintArea = "$A$1:$j$68"
End Sub

How could I do to export the tab "Delivery" at the same time along the tab "Materials", I am frying my brain for a few days but I cant find out a solution, any help please?? thank you in advance...
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to MrExcel,

You can copy an array of worksheets like this...

Code:
Workbooks(wsname).Sheets(Array("Materials", "Delivery")).Copy _
   Before:=Workbooks("HQ 304 Estimate Summary (2018 Rates).XLSM").Sheets(6)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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