Copy a rectangular range of cells with VB

ilya2004

Board Regular
Joined
Mar 17, 2011
Messages
135
Hi everyone,<o:p></o:p>
<o:p></o:p>
I am trying to copy a rectangularrange of cells from one area of the worksheet to another without using the copyand paste function.<o:p></o:p>
<o:p></o:p>
Essentially I am trying to geta code that does the following:<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
Code:
[/FONT][/COLOR]
[COLOR=black][FONT='inherit']Range("A1:B3") =Range("C4:D6")<o:p></o:p>[/FONT][/COLOR]
<o:p></o:p>
<o:p></o:p>
Thanks,<o:p></o:p>
Ilya<o:p></o:p>
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This uses Copy/Paste underneath the surface, but does so in a line of code. It differs from what jonmo1 posted in that it preserves the cell formatting from C4:D6... jonmo1's code only copies the cell values and nothing more (it was not clear to me which functionality you were after)...

Code:
Range("C4:D6").Copy Range("A1")
 
Upvote 0
This uses Copy/Paste underneath the surface, but does so in a line of code. It differs from what jonmo1 posted in that it preserves the cell formatting from C4:D6... jonmo1's code only copies the cell values and nothing more (it was not clear to me which functionality you were after)...

Code:
Range("C4:D6").Copy Range("A1")

Hi Rick,

I actually only want to copy the value of the cells, but I like that your code only makes me specify the location of the first cell instead of the whole range. I would rather only copy the values because in practice this will be selecting ranges of 10,000's of cells and it will be faster to do it that way. Is there a way to do this?

-Ilya
 
Upvote 0

Forum statistics

Threads
1,207,195
Messages
6,077,010
Members
446,250
Latest member
Dontcomehereoften

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