ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying Worksheets (https://www.excelbanter.com/excel-programming/410394-copying-worksheets.html)

James

Copying Worksheets
 
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!

Norman Jones[_2_]

Copying Worksheets
 
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
'<<=========



---
Regards.
Norman


"James" wrote in message
...
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!




All times are GMT +1. The time now is 02:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com