Better way than Range(Selection,Selection.End(xlDown)).copy ?

JamesonMH

Board Regular
Joined
Apr 17, 2018
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Still learning the VBA ropes and I know "select" s/b avoided whenever possible, so I'm posting this.

Assuming data is in Range("C136:E139") and I want to copy the data in D136:D139 I used the code Range(Selection,Selection.End(xlDown)).copy which was straight from the macro recorder...

Is there a more efficient way?

Only other way I came up with was: Range("C136").currentregion.offset(,1).resize(,1).copy

Thanks

James
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Is the initial dataset correct
Range("C136:E139") ??

Code:
Range("D136:D139").copy
 
Last edited:
Upvote 0
Try this...

Code:
Range("C136", Range("C136").End(xlDown)).Offset(0,1).Copy

Thanks AlphaFrog, that's what I was after. I didn't realize Range could be written like that.

Too bad the macro recorder uses "select/selection" all over the place instead of code like you just shared. Good thing for this forum!

Cheers,
James
 
Upvote 0
Is the initial dataset correct
Range("C136:E139") ??

Code:
Range("D136:D139").copy

Sorry if I wasn't too clear what I was after in my original post, Michael. I was looking for a concise way of doing the equivalent of Ctrl+Shift+arrow without using the select/selection that the macro recorder uses.

AlphaFrog posted what I was looking for so all is good.

Cheers
James
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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