copy a sheet in excel to another workbook through macro

Jibanendu

New Member
Joined
Apr 20, 2011
Messages
16
Hi,

I have been trying to copy an excel sheet to another excel sheet through VBA macro. I am new to this macro concept. Currently I have using Ms-Excel 2004 in MAC.

Below is the code that I wanted it to execute but it is showing some problem i.e Run Time Error 9 subscript out of range'

/*****Start of Code******/
Sub Mover2()
ActiveSheet.Move Before:=Workbooks("/Users/jibanendu/desktop/abc.xls").Sheets(1)
'Moves active sheet to beginning of named workbook.
'Replace Test.xls with the full name of the target workbook you want.
End Sub

/*****End of Code******/

Please guide me through and help me out to resolve this error,cause I am in serious need of this.

Thanx in advance,
Jibanendu
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi there,

I do not have Mac, but I think you want to ditch the path to the other workbook. As the destination wb must be open, you should just need abc.xls

Mark
 
Upvote 0
Hi GTO,

Thanks for your help,
Even I tried to open the xls file i.e abc.xls

the file gets opened but nothing is copied from active workbook to abc.xls.

following is my code

Sub Mover2()

Workbooks.Open Filename:="abc.xls"
ActiveSheet.Move Before:=Workbooks("abc.xls").Sheets("Sheet1")

End Sub


PLEASE HELP ME OUT!!

Thanx in advance
Jibanendu
 
Upvote 0
Perhaps

Code:
Sub Mover2()
Dim a As Worksheet
Set a = ActiveSheet
Workbooks.Open Filename:="abc.xls"
a.Move Before:=Workbooks("abc.xls").Sheets("Sheet1")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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