Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Replace Worksheet

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Replace Worksheet


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

"DevDaniel" wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Replace Worksheet

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)


"DevDaniel" wrote in message
...
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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace * on the worksheet leo Excel Discussion (Misc queries) 5 February 6th 09 12:04 AM
Replace #VALUE! in cells of a worksheet Peterpunkin Excel Discussion (Misc queries) 1 May 4th 06 02:07 AM
how do I replace a worksheet. team1 Excel Discussion (Misc queries) 0 March 14th 06 05:24 PM
How do I replace a worksheet with another worksheet in excel Ammnon Excel Worksheet Functions 1 January 12th 05 10:48 AM
Replace worksheet name with a variable monika Excel Programming 3 February 11th 04 03:35 AM


All times are GMT +1. The time now is 07:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"