+ Reply to Thread
Results 1 to 19 of 19

Compare Quantity by Unique ID in two worksheets/Workbook

  1. #1
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Compare Quantity by Unique ID in two worksheets/Workbook

    Dear Members,
    I am looking for a routine that can compare worksheets for the number of quantities requested with the number of quantities ordered against a particular Unique ID. I am expecting the following:

    1. Select ID Column range which needs to be compared in the "Request" sheet.
    2. Select ID Column range to be compared with in "Ordered" Sheet.
    3. Select the Quantity range that needs to be compared in the "Request" sheet.
    4. Select the Quantity range to be compared with in "Ordered" Sheet.
    5. Add quantities against a particular Unique ID before comparing
    3. Put remarks in the third Generated sheet with Unique ID in one column and Remarks like:- Unique ID = B , Add 2 more, Reduce 2 quantities, Missing, Not Ordered etc.


    Please see the below screenshots (Sheet Attached as well) to have an idea of what I am trying to achieve. I have found a similar routine that generates a sheet "change" to compare unique id and color it but I wasn't able to upgrade as per my needs. (Sheet Attached)

    Any help would be highly appreciated. Thanks a lot.

    Also asked at Mrexcel forum : https://www.mrexcel.com/board/thread...kbook.1166980/ (Moderator cleaned up link to activate it -6SJ)
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by 6StringJazzer; 04-03-2021 at 02:48 PM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Dear AliGw,
    Thanks alot. I believe i am able to attach successfully

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

    Re: Compare Quantity by Unique ID in two worksheets/Workbook


    Hi,

    attach at least your own sample workbook rather than one from another thread
    - with a complete crystal clear explanation of the need - as that's very confusing …

    … or you are enough confident with your Excel / VBA skills to amend any generic code some helper may post ?

    All I can do is to ask a VBA beginner kid to rewrite the uggly initial code - as an Excel basics lockdown exercice -
    in order to create the colored data in Changes worksheet but it seems that is not what you are expecting for …

  5. #5
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Quote Originally Posted by Marc L View Post

    Hi,

    attach at least your own sample workbook rather than one from another thread
    - with a complete crystal clear explanation of the need - as that's very confusing …

    … or you are enough confident with your Excel / VBA skills to amend any generic code some helper may post ?

    All I can do is to ask a VBA beginner kid to rewrite the uggly initial code - as an Excel basics lockdown exercice -
    in order to create the colored data in Changes worksheet but it seems that is not what you are expecting for …
    Hi Mark,
    I believe I wrote "I found some similar routine" to indicate that I found this routine. I didn't delete any wording in the code so its is easily understandable but the sheets inside 'yesterday and 'today' are amended as per my need.
    "Material No' and 'Quantity' are getting compared between sheets 'Yesterday and 'Today' same as showed above in my post 'Request' and 'Ordered'.
    'Changes' worksheet is similar to my expected 'Remarks' sheet but with the following differences.
    1. It does add values before comparing 'based on unique id.
    2. Columns 2 is fixed for comparison which I am looking for dynamic.
    3. Rather than color change I am looking for a write-up

    Let me know if its clear or require more explanation. Thanks for your response.

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

    Arrow Re: Compare Quantity by Unique ID in two worksheets/Workbook


    Maybe it could be usefull you clearly elaborate with details points #1 & 2 …

  7. #7
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Quote Originally Posted by Marc L View Post

    Maybe it could be usefull you clearly elaborate with details points #1 & 2 …
    Marc L

    In reference to the Image above, I am looking to compare two sheets with regards to their total quantity as per their ID.

    1. I am looking for a routine to add quantities in the sheet (Order & Request) under the same ID before start comparing.
    2. Report differences as either additional quantity, reduce quantity, not available in a separate sheet ("Remarks"). Refer Image-3 above

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

    Arrow Re: Compare Quantity by Unique ID in two worksheets/Workbook


    Attach your own sample workbook well reflecting the before state and the expected result …

    Or are you able to fit any VBA generic code 'cause of your initial attachment which not relates your need, even its code !
    If not it will be just a waste of time in particular for any helper …

  9. #9
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Quote Originally Posted by Marc L View Post

    Attach your own sample workbook well reflecting the before state and the expected result …

    Or are you able to fit any VBA generic code 'cause of your initial attachment which not relates your need, even its code !
    If not it will be just a waste of time in particular for any helper …
    Marc L,

    Kindly find excel file attached "Compare Quantities - Expected Result".

    I am looking for the following.
    1. Two sheets are compared "Requested" & "Ordered" for their quantities based on their ID regardless of the column number they are located it.
    2. Remarks sheet report differences after summing up the values in both sheets (As per ID) either as "ADDITIONAL", "REDUCE QUANTITY" OR "NOT AVAILABLE" - See Attached Excel File.

    Thanks

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

    Question Last but not least ? …


    As nobody answers so this is the situation on my side : your last attachment does not match your initial post pictures …

    I send it to a VBA beginner kid as an exercice
    - easy just with Excel basics and the Macro Recorder as you can do yourself -
    and he just answers « how can it be possible to make such a bad worksheet design ?! »
    Anyway he succeed to get the expected result.

    But I won't even start to clean his code generated by the Macro Recorder
    without a confirmation that the last attachment is the real layout
    'cause the code may not work well for another design like your initial pictures …
    After confirmation I will post the code and I will not modify it if you forgot anything
    so well think about your need and the real layout before answering …

  11. #11
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Marc, I dont see any difference in my attached sheet 'Compare Quantities - Expected Result' and Image posted above except one line remark statement.

    Regarding your beginner kid I really want to know what is bad worksheet design ?

    I put ID and Quantity in different columns in two worksheets as most of the time the two sheets that we receive for comparison doesn't have the COLUMN fixed for ID & Quantity in terms of Location.

    Would like to hear back from you on how this design is bad.

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

    Arrow Re: Compare Quantity by Unique ID in two worksheets/Workbook


    Usual good design in headers starting in A1, no blank row between headers and data, …

    So check your last attachment and if it does not reflect E X A C T L Y the real layout
    - which is o b v i o u s l y the case according to your initial pictures -
    attach at least the good one or you are very confident with your Excel / VBA skills
    to fit any code to your real workbook so are you able ?

    For ID & Quantity columns : do you mean their positions change everytime in both source sheets ?
    In this case no typo is allowed in headers names like in worksheets names !

  13. #13
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Marc L,
    Yes the position changes in both sheets and I am not expecting it to be attached with the column header name 'ID' rather can be selected as a range from InputBox.

    I already worked out the remaining part of the VBA that is workable for me but the only tough part for me is to take 'column' range input as Input box. So user can do the following.
    1. Select ID Column range which needs to be compared in the "Request" sheet.
    2. Select ID Column range to be compared with in "Ordered" Sheet.
    3. Select the Quantity range that needs to be compared in the "Request" sheet.
    4. Select the Quantity range to be compared with in "Ordered" Sheet.

  14. #14
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  15. #15
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Jeff,
    Thanks for notifying me and apologies for missing out. I posted a similar question Mrexcel today but when I trying to put the link I am getting the following error: You are not allowed to post any kinds of links, images or videos until you post a few times.

    Please let me know if I am missing out on something. Thanks

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Post the link with a few gaps in it, then you will be able to do it.

  17. #17
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    Quote Originally Posted by AliGW View Post
    Post the link with a few gaps in it, then you will be able to do it.
    Thanks AliGW. Edited original post with a link. Hope its acceptable.

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

    Arrow Re: Compare Quantity by Unique ID in two worksheets/Workbook


    Quote Originally Posted by rummaan17 View Post
    I already worked out the remaining part of the VBA that is workable for me but the only tough part for me is to take 'column' range input as Input box
    See Application.InputBox in VBA help, easy …

    In case you need more help, after posting the expected links - a must be since the creation of this thread ! -
    post at least your actual code - the same as links, should be in the initial post ! - with the code tags as per forums rules.

  19. #19
    Registered User
    Join Date
    04-01-2021
    Location
    brunei
    MS-Off Ver
    MS Office 365
    Posts
    10

    Re: Compare Quantity by Unique ID in two worksheets/Workbook

    MarcL,
    I have modified the code shared above to suit my needs. I am working with Application.Inputbox so that I can request two range input that forms part of an array, similar for other sheet before comparison.

    I will post the code soon after tidying it up. 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. compare and highlight unique ID values across worksheets.
    By moondog21 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-11-2019, 03:30 AM
  2. VBA to Compare 2 Worksheets by both a unique identifier row and column header
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 01-30-2017, 04:42 PM
  3. Compare two excel workbooks (or two worksheets within a single workbook)
    By sergiozygmunt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2016, 03:11 AM
  4. Replies: 2
    Last Post: 04-12-2013, 06:20 PM
  5. Compare cell value (date) between two workbook/worksheets before executing vba
    By pr1m35 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2010, 03:05 PM
  6. [SOLVED] how to compare 2 worksheets in 1 workbook
    By Treasur2 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-30-2006, 07:45 AM
  7. [SOLVED] How can I compare worksheets in the same workbook?
    By Malcolm M in forum Excel General
    Replies: 2
    Last Post: 05-16-2005, 12: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