+ Reply to Thread
Results 1 to 11 of 11

VBA Table Comparison

  1. #1
    Registered User
    Join Date
    11-20-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    7

    VBA Table Comparison

    Dear Excel community,
    I'll like to compare excel data.
    These Excel tables are extended or reduced monthly, making it difficult to compare.
    Here is an example of an Excel sheet before using the macro.
    The table columns are not so important.
    The names of the lines in the first column that are to be the order criterion are much more important. They're marked in yellow.

    Here is the BEFORE-Sheet:
    http://www.evernote.com/l/AGDXuafuCe...6MvJYVFkKlO3c/


    The VBA should now always compare the first column with the column that has the most content in common (here is column M). The contents of the columns should then be distributed in such a way that the columns with the same row labels are listed in one row and thus become comparable. No lines may be lost even if they are not comparable with others.
    More than 2 data sets can be compared, unlike in the example. sometimes it can be up to 12 data sets per sheet.
    The number of columns that belong to a data set can also vary.
    Columns A-K and M-W are to be understood as data sets.
    Here is the AFTER-Sheet

    http://www.evernote.com/l/AGDXuafuCe...6MvJYVFkKlO3c/

    I have attached an Excel Sheet in the Links,
    Thank you very much for your Suggestions

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA Table Comparison

    This works for your sample data:
    Please Login or Register  to view this content.
    Not sure how you want it to work with more than 2 data sets - can you provide an example of that, please?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    11-20-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    7

    Re: VBA Table Comparison

    Thank you very, very much for your support.

    Unfortunately I receive an Error Message.
    i posted the screenshot in the Link youŽll find below.
    Thanks again for the support.

    Here is the same workbook extended by 2 more sheets.
    Thanks again.
    Tom

    http://www.evernote.com/l/AGCf8ZQTuC9Ikb63f47SJkqjVuBpS9FxHJQ/"]Thank you very, very much for your support. Here is the same workbook extended by 2 more sheets. Thanks again. Tom http://www.evernote.com/l/AGCf8ZQTuC...qjVuBpS9FxHJQ/[/URL]



    I am so appreciative and happy.
    Last edited by mthwi; 11-20-2017 at 10:07 AM.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA Table Comparison

    Okay - that's a lot more complicated!

    Try this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-20-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    7

    Re: VBA Table Comparison

    This is awesome.
    I only tested the script briefly.
    I'll test it tomorrow with different numbers.

    Thank you so much. I'm really looking forward to it and hope that others in the community can also benefit from this fantastic script.
    You're a god.
    Thank you very much.

  6. #6
    Registered User
    Join Date
    11-20-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    7

    Re: VBA Table Comparison

    Hi Olly,
    I found one Workbook where the script didn't work.
    I Attached it in the existing link above.
    it is calles sample2.xlsx
    In there you'll find a sheet called 'Original'. That is the raw data.
    And another called 'Result'. I created it by hand to show how the result of the script should look like.

    http://www.evernote.com/l/AGCf8ZQTuC...qjVuBpS9FxHJQ/

    Thank you again from the bottom of my heart for your help.
    Bst,
    Tom

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA Table Comparison

    Yeah, that source file has blanks in row 1. All your previous examples followed a pattern of repeating tables by column, with headers in row 1.

    It's REALLY hard to write code for a spec which keeps changing... I can't guess at which data layouts your source data might have!

    Do you have the capacity to delete the blank row at the top of the data in cases like this, or do you need the code to be changed to allow for datasets which may not start at row 1?

    EDIT: That source also has multiple blanks in the header row, and inconsistent number of columns in each region.
    Last edited by Olly; 11-21-2017 at 07:49 AM.

  8. #8
    Registered User
    Join Date
    11-20-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    7

    Re: VBA Table Comparison

    I saw that too and eliminated row 1 but it still doesn't work on my PC.
    I can adapt the tables according to your code as long as contents isn't concerned.

    I guess these blanks were in the other workbooks as well so were the inconsistent columns in each region?

    What Do I have to do with this table to make this incredible Makro work?
    Last edited by mthwi; 11-21-2017 at 08:54 AM.

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA Table Comparison

    Quote Originally Posted by mthwi View Post
    I guess these blanks were in the other workbooks as well?
    No, none of the original spec source data had blank headers for your primary column AND blanks between table regions. It makes it very difficult to work out what the table regions actually are, when they're inconsistent. This latest dataset also doesn't have an value to indicate the end of the rows, either.

    Try this - it test okay for me on all the datasets you've provided so far:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-20-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    7

    Re: VBA Table Comparison

    Hi, Olly,
    i am sooooo sorry, here is another dataset where the script does not work properly.
    It's basically nothing new.
    Could you take another look at it?

    http://www.evernote.com/l/AGADlvmpxv...A-bWPe_H_XZ2c/

    Thank you so much.
    You're awesome.
    Last edited by mthwi; 11-22-2017 at 07:37 AM.

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA Table Comparison

    No. You need to do some manual adjustment to prepare that sheet. There's no way I can write code to determine which ranges you are actually interested in comparing, without any manual input at all. Even looking at it manually, I have no idea what you're expecting the output to look like: You haven't even prepared an expected output for this sheet.

    I think I've taken this about as far as I can, given the ever shifting scope, and lack of specification.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. You can also 'Add Reputation' to those who helped you. Thanks.

+ 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. Complex Table Comparison
    By jordanmh84 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-01-2016, 01:31 PM
  2. Table that includes a comparison
    By economistegypt2010 in forum Excel General
    Replies: 9
    Last Post: 11-24-2014, 11:12 AM
  3. table results comparison
    By BlueHawaiian in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-27-2013, 12:56 PM
  4. Two IF statements with date comparison in Table
    By ExcelWarrior in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-29-2012, 04:25 PM
  5. [SOLVED] Pivot Table row comparison
    By revm2 in forum Excel General
    Replies: 2
    Last Post: 11-02-2005, 06:17 PM
  6. how do I set up a fast comparison table?
    By Biologist in forum Excel General
    Replies: 1
    Last Post: 06-20-2005, 09:05 PM
  7. [SOLVED] pivot table comparison
    By Tim in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2005, 11:06 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