+ Reply to Thread
Results 1 to 10 of 10

Compare 2 columns in different tabs and add new values

  1. #1
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    Compare 2 columns in different tabs and add new values

    In the attached file, there is the Wave 1 List tab and the New Data tab. Everyday, I extract a new report and will compare the IDs against the data in the Wave 1 List. If there are new IDs, I will add it by inserting a new row exactly where the number ID falls as its sorted by the ID column from smallest to largest.

    1. In some cases, no new IDs to add; do nothing
    2. If new IDs in the new data, add to the Wave 1 List based on how it's sorted with out deleting any of the existing ID data, format, color..
    3. Highlight the newly added IDs row (from B to AU) so that I can fill in the other "data" details afterwards

    Since I do this daily, I'm trying to see if this can be automated and take down from 2 hours to potentially 30 mins... thx
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,926

    Re: Compare 2 columns in different tabs and add new values

    In the attached file I loaded both tables into Power Query. Ran an anti join to determine which items were in the new file and not in the old. Mcode for this:

    Please Login or Register  to view this content.
    File attached for your analysis. Run time for this exercise. Less than 2 minutes. To run this daily. Save the file and update the changes to the file by replacing the existing tables with new ones but maintaining the existing table names. Run the Refresh button twice to update the output. To learn more about PQ, click on the links in my signature. Time savings will be enormous
    Attached Files Attached Files
    Last edited by alansidman; 03-31-2020 at 11:57 AM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    Re: Compare 2 columns in different tabs and add new values

    Not sure how this works. I wanted to keep the data as is in the Wave 1 List tab and only insert the new IDs from the "new data" into new rows in the Wave 1 List tab but sorted by ID... Once it inserts then new ID, i need it to highlight that row so I can fill in the details in that row...

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,926

    Re: Compare 2 columns in different tabs and add new values

    What I have provided you is what is new in your report that is not in the old report. Your next step would be to copy and paste the new items to the old ( a quick manual action) and then do what you need to add. My understanding of your issue was to find the new items and isolate them. This is what the PQ merger (anti join) does. There is no change to the original data. This extracts the data to a new file.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,560

    Re: Compare 2 columns in different tabs and add new values

    VBA
    Please Login or Register  to view this content.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    Re: Compare 2 columns in different tabs and add new values

    Try this...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this …


    Near jindon, with the horizontal alignment :

    PHP Code: 
    Sub Demo1()
         
    Dim C%, R&, S&
             
    Application.ScreenUpdating False
        With Sheet1
    .[B3].CurrentRegion
             C 
    = .Columns.Count
             R 
    = .Rows(.Rows.Count).Row 1
             Sheet2
    .[D2].Formula "=ISNA(MATCH(B4," & .Columns(1).Address(External:=True) & ",0))"
        
    End With
        With Sheet2
    .[B3].CurrentRegion
              
    .AdvancedFilter xlFilterInPlace, .Parent.[D1:D2], , True
              
    .Parent.[D2].Clear
               S 
    Application.Subtotal(102, .Columns(1))
            If 
    S Then
                   
    .Offset(1).Copy Sheet1.Cells(R2)
               
    With Sheet1.Cells(R2).Resize(SC)
                   .
    Columns(1).HorizontalAlignment xlCenter
                   
    .Interior.ColorIndex 19
               End With
                    Sheet1
    .[B3].CurrentRegion.Sort Sheet1.[B3], xlAscendingHeader:=xlYes
            End 
    If
                If .
    Parent.FilterMode Then .Parent.ShowAllData
        End With
             Application
    .ScreenUpdating True
    End Sub 
    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 03-31-2020 at 02:13 PM. Reason: optimization …

  8. #8
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    Re: Compare 2 columns in different tabs and add new values

    Hi - I'm using the jindon vba code he provided. It works fine except that I forgot to mention that every time that I have to add a new column right next to the N column to add the new data to compare with previous dates. So when I tried the code, it's not working... probably cause it has more columns? I couldn't figure it out.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,560

    Re: Compare 2 columns in different tabs and add new values

    The code is only comparing col.B data in both sheets, so I don't understand what you are asking.

    If you upload a workbook with before/after, it may help.

  10. #10
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    Re: Compare 2 columns in different tabs and add new values

    Ok, it seems it was my mistake. It works fine... thx

+ 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: 6
    Last Post: 11-02-2018, 06:56 AM
  2. Macro to Compare three columns between two tabs and display differences in a third
    By WildSpreadsheets in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-31-2017, 10:53 PM
  3. Replies: 5
    Last Post: 09-03-2015, 02:08 AM
  4. Replies: 5
    Last Post: 10-26-2013, 01:03 PM
  5. Replies: 0
    Last Post: 10-07-2013, 10:24 AM
  6. Compare 2 columns and copy new values from the 2nd columns to a 3rd column
    By djarcadian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-02-2013, 12:18 PM
  7. Replies: 10
    Last Post: 07-10-2012, 03:01 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