Replace Worksheet

D

DevDaniel

I have:
WorkbookA with Worksheets A, B, C, and D.
WorkbookB with Worksheet Z.

I want:
To replace sheet C with sheet Z (i.e., WorkbookA now contains sheets A, B,
Z, D).

Any suggestions?
 
J

Joel

workbooks("workbookB").worksheets("worksheet Z").copy _
destination:=workbooks("workbookA").worksheets("worksheet C")
workbooks("workbookA").worksheets("worksheet C").name = "worksheet Z"
 
C

Chip Pearson

Try something like

Sub AAA()
Dim WBA As Workbook
Dim WBB As Workbook

Set WBA = Workbooks("WBA.xls") '<<< CHANGE Workbook File Name
Set WBB = Workbooks("WBB.xls") '<<< CHANGE Workbook File Name

Application.DisplayAlerts = False
WBB.Worksheets("SheetZ").Copy after:=WBA.Worksheets("SheetC")
WBA.Worksheets("SheetC").Delete
Application.DisplayAlerts = True
End Sub

This assumes that workbook WBA.xls and workbook WBB.xls are already open.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

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

Top