Results 1 to 14 of 14

Record Macro to Copy / Paste Dynamic Ranges

Threaded View

Steve N. Record Macro to Copy / Paste... 11-01-2013, 10:27 PM
BeachRock Re: Record Macro to Copy /... 11-02-2013, 01:31 AM
Steve N. Re: Record Macro to Copy /... 11-02-2013, 12:54 PM
BeachRock Re: Record Macro to Copy /... 11-02-2013, 01:55 PM
jaslake Re: Record Macro to Copy /... 11-02-2013, 02:33 PM
Steve N. Re: Record Macro to Copy /... 11-02-2013, 03:58 PM
jaslake Re: Record Macro to Copy /... 11-03-2013, 10:31 AM
Steve N. Re: Record Macro to Copy /... 11-03-2013, 07:51 PM
jaslake Re: Record Macro to Copy /... 11-03-2013, 10:33 PM
Steve N. Re: Record Macro to Copy /... 11-03-2013, 11:12 PM
jaslake Re: Record Macro to Copy /... 11-04-2013, 12:07 AM
Steve N. Re: Record Macro to Copy /... 11-04-2013, 10:09 PM
Steve N. Re: Record Macro to Copy /... 11-12-2013, 03:45 PM
jaslake Re: Record Macro to Copy /... 11-12-2013, 08:36 PM
  1. #1
    Forum Contributor Steve N.'s Avatar
    Join Date
    12-22-2011
    Location
    USA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    298

    Record Macro to Copy / Paste Dynamic Ranges

    Good evening.

    I've recorded a Macro (I'm new to this process) that copies and pastes data from two workbooks into a table in yet a 3rd 'Calc' wb. As you can see, the "HIST" file is first followed by the "WIP" file.

    The problem I'm having is that the 'Hist' file varies in number of rows from day to day. Currently, if the Hist file is longer than the file I used when recording the Macro, the WIP file overlaps Historical data. Conversely, on days when the 'Hist' file is shorter, the WIP data is pasted somewhere below the table.

    So, how do I get the WIP data copied and pasted directly beneath the Hist data regardless of the number of rows in the Hist file?

    Thanks, Steve



    Sub GetData()
    '
    ' GetData Macro
    '
    
    '
        Range("WIP[WC]").Select
        ChDir "C:\Users\Steve\Desktop\Test folder"
        Workbooks.Open Filename:="C:\Users\Steve\Desktop\Test folder\HIST.xlsx"
        Range("A2:O2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Windows("Morning Prod Calc (v1.5a).xlsx").Activate
        ActiveSheet.Paste
        Workbooks.Open Filename:="C:\Users\Steve\Desktop\Test folder\WIP.xlsx"
        Range(Selection, Cells(ActiveCell.Row, 1)).Select
        Range("A2:O2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Morning Prod Calc (v1.5a).xlsx").Activate
        Range("A2").Select
        Selection.End(xlDown).Select
        Range("A12").Select
        ActiveSheet.Paste
        Cells.Select
        Cells.EntireColumn.AutoFit
        Range("A2").Select
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 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
  2. Replies: 5
    Last Post: 03-02-2013, 04:22 PM
  3. [SOLVED] Macro to copy and paste Ranges
    By djmarsh51 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-14-2012, 01:58 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. How to record a Macro by copy paste from a worksheet
    By pectin232 in forum Excel General
    Replies: 1
    Last Post: 05-05-2009, 04:10 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