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

JamesonMH

Board Regular
Joined
Apr 17, 2018
Messages
111
Office Version
  1. 365
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
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,751
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Is the initial dataset correct
Range("C136:E139") ??

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

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,381
Assuming data is in Range("C136:E139") and I want to copy the data in D136:D139

Try this...

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

JamesonMH

Board Regular
Joined
Apr 17, 2018
Messages
111
Office Version
  1. 365
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
 

JamesonMH

Board Regular
Joined
Apr 17, 2018
Messages
111
Office Version
  1. 365
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,736
Messages
5,597,815
Members
414,178
Latest member
Octavian Manoli

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