+ Reply to Thread
Results 1 to 4 of 4

Dynamic range fails to copy correctly to new workbook

  1. #1
    Registered User
    Join Date
    04-10-2020
    Location
    Dublin, Ireland
    MS-Off Ver
    Office365
    Posts
    17

    Dynamic range fails to copy correctly to new workbook

    Hi all,

    New to VBA and trying to practice a bit by creating a calendar, but struggling to copy a dynamic range to the new workbook. If I copy to H4:I20 it works fine, but I don't know how many rows will be populated and hence want this to be dynamic.

    I'm using LastRow to count to the last row and then trying to use that to copy only the rows that are populated.

    I feel like I'm missing something very silly and any help would be greatly appreciated.

    Thanks in advance!

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by RuairiO; 05-13-2020 at 02:36 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    31,088

    Re: Dynamic range fails to copy correctly to new workbook

    You need to determine the last row BEFORE you create your new workbook (because that becomes the Active Workbook)

    Try it this way

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-10-2020
    Location
    Dublin, Ireland
    MS-Off Ver
    Office365
    Posts
    17

    Re: Dynamic range fails to copy correctly to new workbook

    Yeah that makes sense... I was pulling my hair out of over this one

    Yeah much appreciated!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    31,088

    Re: Dynamic range fails to copy correctly to new workbook

    You're welcome. Thanks for the rep.

+ 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. [SOLVED] Fails to create a dynamic range
    By mullahraheil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2019, 04:17 AM
  2. Copy dynamic range from closed workbook paste as table into specific sheet
    By Huskersippi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2019, 11:35 PM
  3. Copy dynamic range to a sheet in new workbook with specific format
    By zrs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-05-2019, 01:44 PM
  4. [SOLVED] Dynamic name range not working correctly
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 10
    Last Post: 12-14-2013, 09:09 PM
  5. Copy a range based on dynamic row numbers and paste into another workbook
    By Grizz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2013, 02:07 PM
  6. How to copy a dynamic range with VBA and paste in another workbook?
    By cody4334 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2013, 12:01 AM
  7. Copy dynamic range from closed workbook
    By RedWing in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2011, 07:11 PM

Tags for this Thread

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