VBA for copying entire sheet into new workbook infront of other sheets

xcellrodeo

Board Regular
Joined
Oct 27, 2008
Messages
206
Hi there, I would appreciate some help concerning VBA script. Task: To copy an entire spreadsheet (right click & copy) to new workbook and place the copied spreadsheet infront any pre-existing sheets in the workbook (i.e not overwriting them). The script I currently have is:
Workbooks.Open ("C:\Users\M\Desktop\test1.xlsx") Workbooks("CalRan2013.xlsm").Activate Sheets("Ranking By Month").Select Sheets("Ranking By Month").Copy Before:=Workbooks("test1.xlsx").Sheets(1)
Workbooks("test1.xlsx").Activate
Sheets("Ranking By Month").Select
T1 = InputBox("Enter date of issue in the format 'Mar-13'") Sheets("Ranking By Month").Name = "Issued " & T1
The above script currently overwrites any new sheet copied in. Any help would be much appreciated thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
See if this will work for you.
Code:
Set wb = Workbooks.Open("C:\Users\M\Desktop\test1.xlsx") Workbooks("CalRan2013.xlsm")
ThisWorkbook.Sheets("Ranking By Month").Copy Before:=wb.Sheets(1)
T1 = InputBox("Enter date of issue in the format 'Mar-13'")
wb.Sheets("Ranking By Month").Name = "Issued " & T1
wb.Close True
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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