+ Reply to Thread
Results 1 to 6 of 6

VBA to Copy New Rows from one Table to another Table

  1. #1
    Registered User
    Join Date
    04-29-2017
    Location
    London
    MS-Off Ver
    2016 Professional
    Posts
    50

    VBA to Copy New Rows from one Table to another Table

    Hi All


    I have a spreadsheet that contains 2 tables of data. The rows of each table have a unique id reference in the first column. Table 2 is connected to an external data source. After Table 2 has been refreshed i would like to copy any rows in Table 2 that do not exist in Table 1 to the end of Table 1. A row is determined not to exist in Table 1 if the ID value in Table 2 does not exist in Table 1.

    I have attached a sample spreadsheet and tables


    Using Excel 2010



    Any help or advise appreciated
    Attached Files Attached Files
    Last edited by rabbit_post; 02-23-2022 at 06:37 AM.

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: VBA to Copy New Rows from one Table to another Table

    Here's what I came up with:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA to Copy New Rows from one Table to another Table

    Hi,

    Here's one macro

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    04-29-2017
    Location
    London
    MS-Off Ver
    2016 Professional
    Posts
    50

    Re: VBA to Copy New Rows from one Table to another Table

    Thank you WBD

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA to Copy New Rows from one Table to another Table

    Just be aware, maybe for other applications, that with large ranges using a loop can be time consuming as the code has to jump back and forth between the Excel app and VBA

    It's generally better to filter stuff and do stuff with the filtered range since that only needs one interaction with Excel.

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: VBA to Copy New Rows from one Table to another Table

    Just for fun, I wondered what it could look like in Office 365:

    Please Login or Register  to view this content.
    :D

    WBD

+ 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. Replies: 2
    Last Post: 10-29-2021, 10:04 AM
  2. Macro to search through table and copy all rows with data into another table
    By DaBestEva in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2020, 10:29 AM
  3. Help with table - Copy rows, delete rows, reset table & copy table
    By gkpbydesign in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2019, 10:30 AM
  4. Replies: 0
    Last Post: 08-31-2018, 08:21 AM
  5. copy rows from table with criteria and paste to end of another table
    By PierrePolux in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2018, 08:03 PM
  6. macro to copy table from sheet1 to sheet2 (# of rows in table may vary everytime)
    By arkharova.s in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2014, 03:18 AM
  7. Copy and paste certain rows of a table to create a new table
    By redhawk87 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-12-2013, 12:37 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