Complex Copy&Paste


New Member
Mar 18, 2009
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.



MrExcel MVP, Moderator
May 28, 2005
Office Version
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>


New Member
Mar 18, 2009
Wow. Extremely helpful. Quick turnaround once again. How can you go wrong with these guys? Thank you Peter_SSs!


Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...