Copying Worksheets

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hi,

I would like to copy worksheets from one workbook to another using VBA.

The source workbook has three worksheets (among others) named, LT, ALISE,
FUTURES. I want to copy these three worksheets into a different excel file
that already contains these three worksheets (names are identical).

How do I go about this?

Much appreciated!
 
Hi James,

Try something like:

'=========>>
Option Explicit

Public Sub Tester()
Dim srcWB As Workbook
Dim destWB As Workbook
Dim arr As Variant

arr = VBA.Array("LT", "ALISE", "FUTURES")

Set srcWB = Workbooks("myBook,xls")
Set destWB = Workbooks("myBook2.xls")

With destWB
srcWB.Sheets(arr).Copy After:=.Sheets(.Sheets.Count)
End With
End Sub
'<<=========
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top