+ Reply to Thread
Results 1 to 13 of 13

Copy/Paste Multiple Dynamic Ranges below each other

  1. #1
    Registered User
    Join Date
    11-04-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    29

    Copy/Paste Multiple Dynamic Ranges below each other

    Hello All,

    Could use some help with a macro. I have a workbook with 30+ worksheets. Each worksheet has a range of values, the columns are always the same but the number of rows are different for each sheet - hence dynamic range. What I need is a macro something like that:

    - Go to Sheet 1
    - Copy Range in Sheet 1 (currSheet)
    - Paste in Sheet named "Query"
    - Go to Sheet 2
    - Copy Range in Sheet 2 (currSheet)
    - Paste in Sheet "Query" BELOW the previous range that was pasted
    ---Rinse & Repeat for all worksheets in workbook----

    So basically I would be making a list of the ranges in a sense (if that makes sense)

    I get a "Subscript Out of Range" error at the copy/paste code line:

    Please Login or Register  to view this content.
    Prior to this line I have some code that loops through and does some formatting stuff on all sheets

    Any advice/help would be much appreciated.

    Can't seem to attach the workbook...is there a size limit on uploads?

    Cheers.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    What is the value of LastRow and currSheet??


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    11-04-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    29

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Here is the full code. Let me know if you need the workbook.:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    The full code seems to be ok... but I need a sample file to fix the issue

  5. #5
    Registered User
    Join Date
    11-04-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    29

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Quote Originally Posted by :) Sixthsense :) View Post
    The full code seems to be ok... but I need a sample file to fix the issue
    Is there a cap on the upload file size? The workbook is 2.8MB but won't let me upload...

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Yes, excel file is limited to 1 MB but Zip have 10 MB capacity so add it in zip and attach it

  7. #7
    Registered User
    Join Date
    11-04-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    29

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Genius! Here it is
    Attached Files Attached Files

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Worksheets(currSheet).Range("F2:H" & LastRow).Copy Destination:=Worksheets("Query").Cells(Rows.Count, "A").End(xlUp).Offset(1)
    I found the root cause of the error

    Sheet Named Query is not available in your workbook

  9. #9
    Registered User
    Join Date
    11-04-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    29

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Quote Originally Posted by :) Sixthsense :) View Post
    I found the root cause of the error

    Sheet Named Query is not available in your workbook
    Wow.....I feel retarded...I thought I renamed an empty sheet to that! Jeez. Thanks for the help! sorry for being dumb

    On a similar note, any idea how easy/hard it would be to copy/paste these ranges to a NEW workbook instead of a new sheet in current workbook? I.e. Code to create a new workbook, paste these ranges.
    Last edited by sudric; 01-28-2015 at 07:16 AM.

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Check whether this helps you..

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    11-04-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    29

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Where would you Set the current and new workbook? If i put these outside the first For loop, I get an subscript out of range error at the allSheets line, shown below:

    Please Login or Register  to view this content.
    And I've activated the current and new sheet within the first for loop:

    Please Login or Register  to view this content.

  12. #12
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Check this...

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    11-04-2014
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    29

    Re: Copy/Paste Multiple Dynamic Ranges below each other

    Beautiful! Works greats.

    Thanks a lot man

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Record Macro to Copy / Paste Dynamic Ranges
    By Steve N. in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-12-2013, 08:36 PM
  2. Replies: 0
    Last Post: 08-05-2013, 11:34 AM
  3. Copy and paste dynamic ranges + transforming into a table
    By tigerallied in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2013, 01:26 PM
  4. Copy and paste based on found cells using two spreadsheets with dynamic ranges
    By shawnsonline in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2012, 02:49 PM
  5. copy dynamic ranges in multiple workbooks based on a data in 1 col
    By jbsand1001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-18-2005, 03:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1