copy data from workbook1 to workbook2

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi can anyone help with a line of code to copy data from

workbook1 sheet1 range ("A:AS") to
workbook2 sheet1 range ("A:AS")

Regards

pwill
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Code:
Sub t()
Workbooks(1).Range("A:AS").Copy Workbooks(2).Range("A1")
End Sub
Workbooks(1) Will be the workbook opened first and workbooks(2) will be the workbook opened next. If you have more than two workbooks opened you should be sure that the 1 and 2 refer to the correct workbooks, or close all but the two you want to work with.
 
Upvote 0
Since you gave us no complete Workbook names with extensions.
Modify this script to meet your needs.
This is assuming both Workbooks are open.
Code:
Sub Copy_Data()
Application.ScreenUpdating = False
Workbooks("Book1").Sheets(1).Range("A:AS").Copy Workbooks("Book2").Sheets(1).Range("A:AS")
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Since you gave us no complete Workbook names with extensions.
Modify this script to meet your needs.
This is assuming both Workbooks are open.
Code:
Sub Copy_Data()
Application.ScreenUpdating = False
Workbooks("Book1").Sheets(1).Range("A:AS").Copy Workbooks("Book2").Sheets(1).Range("A:AS")
Application.ScreenUpdating = True
End Sub


Thanks My Aswer Is This, I will give this a try tonight and let you know how I get on.

Regards

pwill
 
Last edited:
Upvote 0
Hi JLGWhiz,

I am getting an error 'subscript out of range' when I try and run the code? would you know why?

Code:
Sub CopyData()

Application.ScreenUpdating = False
Workbooks("Update.xlsm").Sheets(Sheet1).Range("A:AS").Copy Workbooks("Final.xlsm").Sheets(Sheet1).Range("A:AS")
Application.ScreenUpdating = True

End Sub

regards

pwill
 
Upvote 0
Since you gave us no complete Workbook names with extensions.
Modify this script to meet your needs.
This is assuming both Workbooks are open.
Code:
Sub Copy_Data()
Application.ScreenUpdating = False
Workbooks("Book1").Sheets(1).Range("A:AS").Copy Workbooks("Book2").Sheets(1).Range("A:AS")
Application.ScreenUpdating = True
End Sub

Hi My Aswer Is This

I am getting an error 'subscript out of range' when I try and run the code? would you know why?

Code:
Sub CopyData()

Application.ScreenUpdating = False
Workbooks("Update.xlsm").Sheets(Sheet1).Range("A:AS").Copy Workbooks("Final.xlsm").Sheets(Sheet1).Range("A:AS")
Application.ScreenUpdating = True

End Sub


regards

pwill
 
Upvote 0
Are you asking questions about my script or the other post you showed here?

And my script worked for me but you must see I used generic terms since you did not give specific workbook names.

Did you try my script?
 
Upvote 0
Are you asking questions about my script or the other post you showed here?

And my script worked for me but you must see I used generic terms since you did not give specific workbook names.

Did you try my script?
@My Aswer Is This, it looks to me like it is your script with the actual workbook names substituted. @pwill, You need quote marks around your sheet names to make them string values.
 
Last edited:
Upvote 0
If your going to use this script it needed sheet names in quotes like show below:

Code:
Sub CopyData()
'Modified 1-26-18 8:15 PM EST
Application.ScreenUpdating = False
Workbooks("Update.xlsm").Sheets("Sheet1").Range("A:AS").Copy Workbooks("Final.xlsm").Sheets("Sheet1").Range("A:AS")
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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