+ Reply to Thread
Results 1 to 8 of 8

Compare variable by variable and retrieve it

  1. #1
    Registered User
    Join Date
    10-20-2020
    Location
    UK
    MS-Off Ver
    2013
    Posts
    13

    Compare variable by variable and retrieve it

    Hi,
    I want to compare variable by variable from respective dataset between master and child sheet. If there is any discrepancy, I want to make any one colour to that cell and copy entire row into discrepancy sheet.
    e.g.
    AELLTCD variable length "11" from AE of child sheet is not matching with master dataset having value as "8".
    Spelling error of AEDECOD variable from child mismatch with AEDECODE variable from master.

    Attaching excel file for reference
    Here Orange color is used for the value with discrepancy. Any color can be used to do the same
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-20-2020
    Location
    UK
    MS-Off Ver
    2013
    Posts
    13

    Re: Compare variable by variable and retrieve it

    can anyone help my query

  3. #3
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Compare variable by variable and retrieve it

    I wrote code to compare by cell from the master to the child page. The issue I see is that one page has to be considered the master. I don't see how I can first use the master page as the as the master than use the child page as the master to compare back to the master.

    That said, my current comparison recreates a line for each discrepancy, which is not what is required. Here is the code, but it is not complete. I recommend any new lines be placed at the end, not in the middle as has been done.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Compare variable by variable and retrieve it

    I corrected the population of the discrepancy lines. Let us know how it goes.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-20-2020
    Location
    UK
    MS-Off Ver
    2013
    Posts
    13

    Re: Compare variable by variable and retrieve it

    Thanks maniacb for your great work. Its not working for few records where variable from col2 is present twice or more.
    I sorted the data based on dataset and variable and place some same record in the macro sheet. However, it is not working. Attaching excel file
    Please check
    Attached Files Attached Files
    Last edited by abraham123; 10-27-2020 at 07:08 AM. Reason: Attaching excel file

  6. #6
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Compare variable by variable and retrieve it

    I made some changes to your data. The Length column has numbers in the child page and text in the master page, that is why they show up as different. The blank columns F-G & K-M actually have non-visible data so after I delete those cells they don't show up as different. Try running the code now.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-20-2020
    Location
    UK
    MS-Off Ver
    2013
    Posts
    13

    Re: Compare variable by variable and retrieve it

    Its working fine. is it possible to make changes in the conversion in the code itself for this column so that manual work to be reduced.

    -->One more issue, some of the carriage return are there in the column for which it is showing mismatch. e.g. "Category for Lab Test" is high-lighted for LBCAT variable for both sheet as the master sheet contain one carriage return.
    Is it possible to remove it so that the program will ignore those records along with some extra space.

    Thanks once again for your great help

  8. #8
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Compare variable by variable and retrieve it

    I have included code to remove leading and trailing spaces to improve the matches.


    Please Login or Register  to view this content.

+ 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. [SOLVED] Compare Two Columns, Highlight Variable and Place on New Row
    By Jim Clayton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2018, 12:47 PM
  2. Excel CustomUI Ribbon - Retrieve Variable Value from another Sub ()
    By Mota in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-15-2017, 09:48 PM
  3. variable formula to retrieve unique values from multiple criteria
    By deanusa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-22-2016, 05:13 PM
  4. Replies: 3
    Last Post: 01-13-2014, 12:46 PM
  5. Replies: 4
    Last Post: 07-12-2013, 12:14 PM
  6. Compare offset to a range variable
    By GaidenFocus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2012, 04:17 PM
  7. I need a formula to compare 2 variable.
    By c1steady in forum Excel General
    Replies: 1
    Last Post: 10-13-2010, 05:53 AM

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