Copy after

Venkat Anvekar

New Member
Joined
Mar 22, 2011
Messages
12
Dear Sirs.

I am trying to copy a sheet from one workbook to another using the following code.
A few days back the same code worked but now it is giving an error" subscript out of range" on the copy after statement.

Sheets("MS").Select
PathName1 = Range("v2").Value
pathname2 = Range("P8").Value
pathname3 = Range("u8").Value
filename1 = Range("v6").Value
ControlFile = ActiveWorkbook.Name
Workbooks.Open Filename:=PathName1 & pathname2 & "\" & pathname3 & "\" & filename1
ActiveSheet.Name = "MS"
Worksheets("MS").Copy After:=Workbooks(filename1).Worksheets(1)

Kinldy give your suggestions pls.
Thanks & regards

Venkat
 

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.
Many thanks Mr. Tuelor for the response.

I have to put this code on a "click" of a button which is on the sheet "MS"

On the click of the button i wish to copy the entire sheet "MS" into another workbook which is exiting at a different location.

Pls suggest.
Venkat
 
Upvote 0
Where have you put that code?

Sir.
I have to put this code on a "click" of a button which is on the sheet "MS"

On the click of the button i wish to copy the entire sheet "MS" into another workbook which is existing at a different location. The path of the existing file is referred in the sheet "MS"

Pls suggest.
Venkat
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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