+ Reply to Thread
Results 1 to 12 of 12

Compare two values in different WBs' or sheets' cells and return data

  1. #1
    Registered User
    Join Date
    02-05-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    12

    Question Compare two values in different WBs' or sheets' cells and return data

    Hello masterminds,
    I am doing a large product listing whereas the different products have different properties listed.

    I now need to find all listed properties for each product and gather that data to Sheet1.

    Please see the attached sample file.
    Master data is in Sheet2 (this is where I would search) and Sheet1 where I would like to compile the data to only one product code per row and to to each property's column respectively.
    Macro should run as long as there are product codes found in Column C in Sheet1.

    No macro-example attached, since I didn't know how to approach this, but I made the wanted result as an example to Sheet1.

    Many thanks for this help, as I believe this will be a piece of cake for most, if not all of you guru's here
    Attached Files Attached Files
    Last edited by ETalvitie; 06-13-2021 at 04:09 AM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compare two values in different WBs' or sheets' cells and return data

    A formula could do the job
    E3==IF(SUMPRODUCT((Sheet2!$C$3:$C$26=$C3)*(Sheet2!$E$3:$E$26=E$2))=1;E$2;"")
    - Battle without fear gives no glory - Just try

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

    Re: Compare two values in different WBs' or sheets' cells and return data

    Try the attached.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Compare two values in different WBs' or sheets' cells and return data

    Another one
    Please Login or Register  to view this content.
    Last edited by PCI; 06-13-2021 at 06:10 AM. Reason: Screen freeze added

  5. #5
    Registered User
    Join Date
    02-05-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    12
    Quote Originally Posted by PCI View Post
    A formula could do the job
    E3==IF(SUMPRODUCT((Sheet2!$C$3:$C$26=$C3)*(Sheet2!$E$3:$E$26=E$2))=1;E$2;"")

    This works, but seems to be too heavy with around 1500 product/rows.
    Excel stops working.

  6. #6
    Registered User
    Join Date
    02-05-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    12

    Re: Compare two values in different WBs' or sheets' cells and return data

    Files for testing.
    Attached Files Attached Files
    Last edited by ETalvitie; 06-13-2021 at 07:14 AM.

  7. #7
    Registered User
    Join Date
    02-05-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    12

    Re: Compare two values in different WBs' or sheets' cells and return data

    Quote Originally Posted by jindon View Post
    Try the attached.
    Please Login or Register  to view this content.

    Thank you! This does the trick but since this code is way too advanced for my skills, I don't know how to change and implement this code to my actual masterdata and target file.

    I also need that the code does not copy the search attribute from Row2 because if I change it to anything else, then it does not work as it should.
    So it should check what the property is in Row2, then do the search based on that criteria.


    I attached the actual masterdata file and the target file format, so you can see what I try to accomplish a bit better maybe.

    The properties listed are in MasterDataSample-file in column M --> these properties might change or there can be more others someday, so I must be able to determine the text / search criteria in TargetFileExample Row1 / columns U:AM .

    I need to have the data brought to TargetFileExample columns U:AM, starting from Row2.

    I added the files above in a new post.

  8. #8
    Registered User
    Join Date
    02-05-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    12

    Re: Compare two values in different WBs' or sheets' cells and return data

    Quote Originally Posted by PCI View Post
    Another one
    Please Login or Register  to view this content.

    Maybe I don't know how to use this but it gives an error "Object required" and the code stops in

    'For Each Rg In WkRg'

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

    Re: Compare two values in different WBs' or sheets' cells and return data

    If this is not what you wanted, edit or create the code for yourself.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    02-05-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    12

    Re: Compare two values in different WBs' or sheets' cells and return data

    Quote Originally Posted by jindon View Post
    If this is not what you wanted, edit or create the code for yourself.
    Please Login or Register  to view this content.

    I appreciate the help, but the code does not work. It stops to line

    'If a(i, 2) <> "" Then'


    I don't know how to fix this so I will continue to find some other options.

    Thank you anyway.

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

    Re: Compare two values in different WBs' or sheets' cells and return data

    Error? no way.
    TargetFileSample.xlsx must be open.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    02-05-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    12

    Re: Compare two values in different WBs' or sheets' cells and return data

    Quote Originally Posted by jindon View Post
    Error? no way.
    TargetFileSample.xlsx must be open.
    With Workbooks("targetfilesample.xlsx") <-- I changed this to my actual target filename.

    It works with this example, but for some reason when I change the workbook name in the code to match the my actual target file, it gives the error, even if the target file is open.

+ 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 2 sheets and return values for similar products nr
    By bilglassrolf in forum Excel General
    Replies: 5
    Last Post: 02-05-2019, 06:03 AM
  2. [SOLVED] Compare 3 cells and return various values
    By alanina in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2015, 06:31 AM
  3. Compare cells of an array to return only the unique values
    By goodm009 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-17-2013, 03:00 PM
  4. Replies: 3
    Last Post: 01-02-2013, 10:06 PM
  5. Replies: 1
    Last Post: 10-28-2011, 03:13 AM
  6. Replies: 3
    Last Post: 01-20-2011, 11:22 AM
  7. Compare fields in two sheets ... return associated data to third sheet
    By delirium in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2010, 01:42 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