+ Reply to Thread
Results 1 to 3 of 3

Adding New Rows to a table from another table

  1. #1
    Registered User
    Join Date
    10-11-2016
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    49

    Question Adding New Rows to a table from another table

    Morning All,

    I had an idea which someone else might have done but I am not sure what to search for.

    So I have 1 large table which is combining 10 other tables on different worksheets into one. I have the code to combine the sheets and it works just fine (see below) but I want to make it more clever (poor English). I want it to check the sub tables for new items and add them to the main table. It would need to check all columns to confirm the item is new before copying them over. I have to say most of the coding I have done so far has been Googled so I have no bright ideas on fixing it.

    Thanks in advance

    Robin

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Adding New Rows to a table from another table

    Quote Originally Posted by rpjwhite View Post
    ....So I have 1 large table which is combining 10 other tables on different worksheets into one. I have the code to combine the sheets and it works just fine (see below) but I want to make it more clever (poor English). I want it to check the sub tables for new items and add them to the main table. It would need to check all columns to confirm the item is new before copying them over. .....
    Hi Robin.
    I think I catch the general drift of what you are asking.

    I highly expect someone has done something similar before, but I do not think you can effectively search for that sort of thing. If you have a month free then do a Google search with variations of “vba merge worksheet data based on criteria” then expect a thousand links, one of which might coincidentally do exactly what you want.

    I have been thinking myself about copying and / or selecting data depending on whether it is “new”
    The obvious “unclever” way would just be to mark all cells , possibly with some Formatting , after every “update” of your master you do. Then next time around the unmarked Cells would be copied. ( That could be advantageous of course for you to see what is old data ).

    I think if you are fairly happy with the code you are using now, then you know probably what you will have to do for your new requirement: You will need at every Worksheet to go through the columns and copy just the new data, then adding that on to the corresponding Master Worksheet columns. I expect you may have an idea how to do that?.

    As for “Clever” stuff
    That will depend a lot on your actual data type and layout. I expect the “clever” things might involve using the VBA Special Cells Method to get quickly at new entries in a column.

    But these things will be using so called ( by me anyway ) “spreadsheet interaction techniques”. Whether they are in end effect “clever” or just look “clever” will depend on your data type and layout. Sometimes if you use VBA “Array techniques” that look more boring they may be more efficient.

    I can think of some “semi clever” ideas for part of the problem.

    Like, pseudo, for one column, if you have a start situation of this_.....

    Using Excel 2007 32 bit
    Row\Col
    A
    1
    OldData1
    2
    NewData1
    3
    NewData2
    4
    OldData2
    5
    OldData3
    6
    NewData3
    Worksheet: Sheet1

    Row\Col
    A
    1
    ExistingData1
    2
    ExistingData2
    3
    ExistingData3
    Worksheet: SummarySheet

    _....then in a fairly “clever way” I could copy the new data and paste it into the Summary sheet for each column in one go such that you get_....

    Row\Col
    A
    1
    ExistingData1
    2
    ExistingData2
    3
    ExistingData3
    4
    NewData1
    5
    NewData2
    6
    NewData3
    Worksheet: SummarySheet

    _..... then in a fairly “clever” way I could “mark” all the Cells in “Sheet1” such that they "look" to VBA as not new data.

    Basically I am thinking of messing about with the data such that to us it “looks” to us in exactly the same format regardless of if it is new or old data. But to VBA it will be able to distinguish between the two.
    I am thinking of messing about with whether a number “looks” to VBA as a number or text and / or similarly messing about such that an entry might "look" to VBA as either a formula or a value.
    We would see everything the same, but VBA could distinguish through the VBA special Cells Method as it would see the data Type as different.

    But once again the exact implementation will depend on your data type and layout

    If you want more help we will probably need to see a bit of sample data.
    Here some notes on that:
    http://www.excelforum.com/showthread...42#post4532042

    I will probably be mucking about with my data in a day or so. So if in the meantime you get some test data across and you or no one else sorts it out for you, then I can take as look at your stuff when I look at mine.

    Alan
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  3. #3
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Adding New Rows to a table from another table

    Hi,
    It would be better if we could look at sample of your data but anyway.
    My suggestion is to take some unique value from Main table (main thing is - it has to be unique for each record). As option several columns values can be concatenated and be used as indentificator.
    Then create Scripting.Dictionary and put all identificators in this Dictionary.
    After that loop throw all data sheets and check if each row indetificator Exists in Dictionary. In case it is in our Dictionary - then it is old record, if not - then it`s new and should be copied.
    If there are lot of data in your data base then you can use arrays, search should work much faster.

+ 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: 13
    Last Post: 07-16-2016, 10:53 PM
  2. adding rows to a table
    By stephme55 in forum Excel General
    Replies: 2
    Last Post: 02-15-2016, 03:43 AM
  3. [SOLVED] Adding a row in a table corrupts formula in a summary table (2nd table)
    By How How in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2015, 02:35 PM
  4. Adding rows to locked table
    By xrajncajnx in forum Excel General
    Replies: 2
    Last Post: 09-03-2014, 08:00 AM
  5. Expand a table by adding rows ( table feature 2007 and later)
    By Pepe Le Mokko in forum Excel General
    Replies: 3
    Last Post: 08-13-2013, 05:12 AM
  6. adding rows to a table
    By sportsranker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-22-2008, 10:22 AM
  7. adding rows to pivot table
    By cwinters in forum Excel General
    Replies: 2
    Last Post: 06-06-2005, 02:05 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