Complex Copy&Paste

vfa

New Member
Joined
Mar 18, 2009
Messages
4
I posted for the first time a little while ago and was pleasantly surprised with how fast--and awesome--the response was. Silly me, I really should have asked what I'm about to post here but I honestly don't know if this entire copy and paste project can be turned into a macro. So here goes my attempt at explaining the entire procedure I'm doing manually at the moment...please reply if it's unclear in any way. Thanks for reading/attempting this...

Here's an example of what I'm doing:

I have 4 adjacent columns with headers across the top row and data going down to say row 101 to make it simple--so including the headers lets say the entire thing is A1:D101. I've also named ranges within it. For example, rangeA is A2:D11, rangeB is A12:D21, all the way down to row 101 for a total of 10 named ranges, A through J. Note that each range has the exact same number of rows and columns, 10 rows and 4 columns in this example. So what I want to do is copy RangeA from worksheet1, paste into worksheet2, AND paste the other ranges directly adjacent but only 1 range at a time. See below to see what I mean:

RangeA RangeB (together would be 8 columns wide, 900 rows down)
RangeA RangeC
RangeA RangeD
RangeA RangeE
RangeA RangeF
RangeA RangeG
RangeA RangeH
RangeA RangeI
RangeA RangeJ
RangeB RangeA
RangeB RangeC
RangeB RangeD
RangeB RangeE...and so on down to the end

Some files have 7 "ranges," others less, some more. What is consistent is the data formate and each range is equal in size.

Once again, thank you for your time and effort with this project.

VFA
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
See if something like this gets you started.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> CopyRanges()<br>    <SPAN style="color:#00007F">Dim</SPAN> r <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, s <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, c <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    c = ActiveWorkbook.Names.Count<br>    <SPAN style="color:#00007F">For</SPAN> r = 1 <SPAN style="color:#00007F">To</SPAN> c<br>        <SPAN style="color:#00007F">For</SPAN> s = 1 <SPAN style="color:#00007F">To</SPAN> c<br>            <SPAN style="color:#00007F">If</SPAN> s <> r <SPAN style="color:#00007F">Then</SPAN><br>            Range(ActiveWorkbook.Names(r)).Copy Destination:= _<br>                Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)<br>            Range(ActiveWorkbook.Names(s)).Copy Destination:= _<br>                Sheets("Sheet2").Range("E" & Rows.Count).End(xlUp).Offset(1)<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> s<br>    <SPAN style="color:#00007F">Next</SPAN> r<br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Wow. Extremely helpful. Quick turnaround once again. How can you go wrong with these guys? Thank you Peter_SSs!

VFA
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

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