[Solved] Range as part of a range

BrianDP1977

Board Regular
Joined
Nov 5, 2005
Messages
146
I have the following code to take a given range then output the first two rows in this range as a different range.

Code:
    Range("Ext_DP6_P1_all").Rows("1:2").Copy _
    Destination:=Range("Trunc_DP6_P1").Cells(1, 1)
However, I only want to pass the values (not all the formatting). Also, the code is currently very processor intensive (take a long time to run for some reason). I think it's because it copies and pastes ALL rows in the cell (which is what I thought I wanted at first). However, since it takes so long to work, how do I restrict it to just inputting cells withing the given ranges? Thanks.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Sorry about that. I guess I didn't do a good job defining my variables.

Ext_DP6_P1_All is the first range containing all the rows of data.
Trunc_DP6_P1 is the truncated range where only the first two rows of the original data will be displayed.

Just to reiterate, I want to take the first two rows of information within the first range (just the cells comprising the first two rows of the range and not the entire row on the sheet), copy only the values of these two rows (and maybe the border formats), and paste them to the cells comprising the truncated range. Thank you.
 
Upvote 0
With some help I now have some working code:

Code:
Dim r1 As Range, r2 As Range
Set r1 = Range("Ext_DP6_P1_all").Resize(2)
Set r2 = Range("Trunc_DP6_P1")
r2.Value = r1.Value

The whole "processor intensive" thing had nothing to do with the code. Instead it was caused by the fact that I had the activation set to a worksheet change. This caused the code to re-run everytime it inserted values into the new range's cells. Big mistake. Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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