Replacing Worksheets Using An Exterior Workbook

soteman2005

New Member
Joined
Nov 24, 2005
Messages
32
Hi,

I would like to open a workbook whose name is defined in named range "Welcome_Overrides_Factbase_Selected_Name" in a workbook called "Test1_Adam_20_12_05_2", then copy 4 sheets, ("sheet1","sheet2","sheet3","sheet4") from the just opened workbook to "Test1", replacing sheets ("sheet1","sheet2","sheet3","sheet4") , which already exist in the workbook. Then close the initially open workbook.

Is this possible, and could I save the new workbook with a name that takes the original workbooks name, except the Test1 part i.e. "Test2_Adam_20_12_05_2"?

I am quite stuck on this one so any help would be greatly appreciated.


Thanks

Adam
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Adam

Does this work?
Code:
Dim wbThis As Workbook
Dim wbOpen As Workbook
Dim arrSheets

Set wbThis = ThisWorkbook
Set wbOpen = Workbooks.Open(Range("Welcome_Overrides_Factbase_Selected_Name"))

arrSheets = Array("sheet1","sheet2","sheet3","sheet4")

wbThis.Worksheets(arrSheets).Delete

wbOpen.Worksheets.Copy After:=wbThis.Worksheets(wbThis.Worksheets.Count)

wbOpen.Close
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,064
Members
448,941
Latest member
AlphaRino

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