Copy sheet from Workbook 1 and move to the end Workbook 2

IAP

New Member
Joined
Aug 6, 2020
Messages
8
Office Version
  1. 2010
Platform
  1. Windows
I have Tried using almost every code on the internet and just tried MrExcels code below, and I just keep getting errors.
Sub CopySheetToNewPage ()
Workbooks.Open Filename:="C:\Users\jfjen\Desktop\New Mold Program\AAA Master File\Location Forms.xlsm"
Sheets("Location 2").Copy After:=Workbooks("A12.Basic Reports.xlsm").Sheets(Sheets.Count)
ActiveSheet.Name = "Location 2"
Workbooks("A12.Basic Reports.xlsm").Close savechanges:=False
End Sub

Workbook name - Location Forms.xlsm has a sheet named Location 2.
I want to copy and Paste sheet named Location 2 into Workbook named A12.Basic Reports.xlsm
After a sheet named Location 1
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,794
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
Sub CopySheetToNewPage()
   Workbooks.Open Filename:="C:\Users\jfjen\Desktop\New Mold Program\AAA Master File\Location Forms.xlsm"
   Sheets("Location 2").Copy , Workbooks("A12.Basic Reports.xlsm").Sheets("Location 1")
   Workbooks("A12.Basic Reports.xlsm").Close True
End Sub
 

IAP

New Member
Joined
Aug 6, 2020
Messages
8
Office Version
  1. 2010
Platform
  1. Windows
Thank You for the Reply
workBooks.Open filename:="C:\Users\jfjen\Desktop\New Mold Program\AAA Master File\Location Forms.xlsm"
This line is Highlighted in yellow.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,794
Office Version
  1. 365
Platform
  1. Windows
Does that file exist in that location?
 

IAP

New Member
Joined
Aug 6, 2020
Messages
8
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

Does that file exist in that location?
Yes, Just Checked. I did notice there was a space missing in that line and corrected.
However, now the next line is highlighted
Sheets("Location 2").Copy , Workbooks("A12.Basic Reports.xlsm").Sheets("Location 1")
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,794
Office Version
  1. 365
Platform
  1. Windows
What error message & number do you get?
 

IAP

New Member
Joined
Aug 6, 2020
Messages
8
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

What error message & number do you get?
Run-time error'9'
Subscript out of range
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,794
Office Version
  1. 365
Platform
  1. Windows
In that case check that the sheet name are correct (no leading trailing spaces) & also check the workbook name is correct.
 

IAP

New Member
Joined
Aug 6, 2020
Messages
8
Office Version
  1. 2010
Platform
  1. Windows
In that case check that the sheet name are correct (no leading trailing spaces) & also check the workbook name is correct.
I did as you suggested and tried to erase here and there and then put back blindly, but nothing changed.
This is what I got on almost every code that I uploaded to try and make this work.
 

IAP

New Member
Joined
Aug 6, 2020
Messages
8
Office Version
  1. 2010
Platform
  1. Windows
I did, Nothing changed. See Below
Sub CopySheetToNewPage()
workBooks.Open filename:="C:\Users\jfjen\Desktop\New Mold Program\AAA Master File\Location Forms.xlsm"
Sheets("Location1").Copy , workBooks("A12.Basic Report.xlsm").Sheets("Location 2")
workBooks("A12.Basic Reports.xlsm").Close True
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,128,107
Messages
5,628,720
Members
416,333
Latest member
Time2Learn

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
Top