Professional code require for recorded macro

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
To, All experts,
pls provide me some professional code for below line of code..So i can learn the new..

Code:
Windows("Book1.xlsm").Activate
Sheets("sheet1").Select
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Book2.xlsm").Activate
Sheets("abc").Select
Range("A2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A2").Select
 
Last edited by a moderator:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Something like
Code:
Workbooks("Book1.xlsm").Sheets("sheet1").Range("A2").CurrentRegion.Copy Destination:=Workbooks("Book2.xlsm").Sheets("abc").Range("A2")
 
Upvote 0
Something like
Code:
Workbooks("Book1.xlsm").Sheets("sheet1").Range("A2").CurrentRegion.Copy Destination:=Workbooks("Book2.xlsm").Sheets("abc").Range("A2")

Hi, Thnks for your quick reply...

But it gives me an error....subscript out of range
 
Upvote 0
Do you have
1) an open workbook called Book1.xlsm
2) a sheet in the above workbook called sheet1
3) data in A2 of above sheet/workbook
4) an open workbook called book2.xlsm
5) a sheet in book2 called abc
 
Upvote 0
Hi Fluff,
This is the corrected one..
Workbooks("Book1.xls").Sheets("sheet1").Range("A2").CurrentRegion.Copy _
Destination:=Workbooks("Book2.xlsm").Sheets("abc").Range("A2")
 
Upvote 0
Hello, Can anyone please provide nice code of line for my query please....
 
Upvote 0
I'm afraid I don't understand what you mean. Could you please explain

Workbooks("Book1.xls").Sheets("sheet1").Range("A2").CurrentRegion.Copy _
Destination:=Workbooks("Book2.xlsm").Sheets("abc").Range("A2")

it giving me an error, subscript out of range..Run time error 9..

therefore, I added, 2 line above to this code..

Sheets("sheet1").Select
Range("A2").Select
Workbooks("Book1.xls").Sheets("sheet1").Range("A2").CurrentRegion.Copy _
Destination:=Workbooks("Book2.xlsm").Sheets("abc").Range("A2")
 
Upvote 0
In that case could you please answer my questions from post#4
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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