+ Reply to Thread
Results 1 to 11 of 11

Can this be done with lookup?

  1. #1
    Registered User
    Join Date
    05-31-2007
    Posts
    49

    Can this be done with lookup?

    Hi

    Again i need some help!

    I have two seperate excel files and am trying to automatically pupulate a column in one of the files based on some criterias. will do my best to explain as simply and clearly as possible:

    File 1:
    Column A Column B Column C
    Item Code No ordered Price

    File 2:

    This file has a table based on two things:

    No ordered (e.g. 1/ 50/100)

    Item Code (same as item code in File 1) Price of item based on quantity ordered


    Is it possible to update column C in file 1 with a price based on the table in file 2. i.e. if a customer orders 100 qty of item 100, price is X. If customer orders 250 quantities price is Y?

    I am not sure if the formating in above tables will keep when i post the question, so apologies if its not very clear.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,811

    Re: Can this be done with lookup?

    Here are two solutions:

    http://articles.excelyogi.com/multip...el/2009/03/16/

    http://articles.excelyogi.com/vlooku...el/2009/02/09/

    If you wish for an alternative to these, then google: excel vlookup multiple criteria

    There you will find many hits.

    Alan
    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
    Registered User
    Join Date
    05-31-2007
    Posts
    49

    Re: Can this be done with lookup?

    Hi

    Sorry i wasnt clear in the first post, and boss has changed the criteria!

    I now need to lookup a code based on number of quantities ordered. i hope its clear from the attachment!

    I am attaching a template which shows two input tables and output which i would like. can someone pl help!
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,811

    Re: Can this be done with lookup?

    Would you explain the relationship between the quantity ordered and the item code as the last three don't seem logical to me.

    Alan

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Can this be done with lookup?

    Part of the problem might be that all of your lookup values are A1 descending except 1001 which is A1 descending,

    All must be either Ascending or Descending.
    (I have assumed Descending as this is the majority.)

    Try this rather crude formula to see if it works for you
    In C32
    Please Login or Register  to view this content.
    Drag/Fill Down as required.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  6. #6
    Registered User
    Join Date
    05-31-2007
    Posts
    49

    Re: Can this be done with lookup?

    Alan- Sorry for that, it was a mistake by me.

    Attached is the updated file.

    Basically, say for item no 4000, qty ordered is 275, then i want item code B3 (not B2 or C1 because its less than 275 and not A1, A2 and B2). Not sure how to exactly put it in words.......
    Attached Files Attached Files

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,811

    Re: Can this be done with lookup?

    I tried Marcol's solution and it worked for all but item 1001, but that item is in ascending order and not descending like the others. Change up to all descending and make sure to give Marcol some rep for his solution.

    Alan

  8. #8
    Registered User
    Join Date
    05-31-2007
    Posts
    49

    Re: Can this be done with lookup?

    Many thanks to Marcol for the solution.

    However is there a formula to do this without sorting. thing is that spreadsheet has over 1000 records and they are sorted by customers reference numbers and date rather than item code no!

    Thanks again!

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Can this be done with lookup?

    It's not the sorting of the table that's the problem, it's the logic that is in question.

    All except 1001 seem to have C1 as the lowest pricing level and A1 as the highest

    Have a look at the workbook in post #5

    I moved, and marked red what you have, and replaced it in yellow what I think it should be.

    Am I wrong?

  10. #10
    Registered User
    Join Date
    05-31-2007
    Posts
    49

    Re: Can this be done with lookup?

    Quote Originally Posted by Marcol View Post
    It's not the sorting of the table that's the problem, it's the logic that is in question.

    All except 1001 seem to have C1 as the lowest pricing level and A1 as the highest

    Have a look at the workbook in post #5

    I moved, and marked red what you have, and replaced it in yellow what I think it should be.

    Am I wrong?
    Thanks for your reply. However my spreadsheet in post 6 is correct. The descrepency with 1001 is there but it is what we have on the system. we also have other items for which C1 is not the lowest.

    What i want is for example for item no 500, 85 qty has been ordered. I want to "look" across the second table, find the cell that is the next highest after 85 so in this case it will be C19 and then look up the item code which is A2. I am attaching the file again. thanks for your help again.
    Attached Files Attached Files

  11. #11
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Can this be done with lookup?

    This is not easy to solve using lookup formulae, unless you fix all your data descending.

    MATCH() will return values less than, exact match, and greater than, but the data must be sorted descending.

    LOOKUP() and HLOOKUP() work with lists ascending, but will return the highest value that is less than the lookup value if no exact match is found.
    You are asking for lowest value that is greater than the lookup value if no exact match is found.

    One way around this is to use a formula to reverse the lookup list to descending when it is required to do so.

    In H19
    Please Login or Register  to view this content.
    Drag Across to Column M then down as required.

    We can now use this as an alternative lookup table when the original table row is ascending.
    In Sheet1 C31 this mouthful
    Please Login or Register  to view this content.
    Drag/Fill Down

    This might be easier to follow if we use named ranges, see Sheet "Names", these can be dynamic in your final worksheet.
    Please Login or Register  to view this content.
    I have added conditional formatting to highlight when the list is ascending and the alternative table is used for the lookups.

    The extra header ascending row is only for reference to see the values returned, it is not requred for the formula.

    I can't work out why you think the result for 1001 x 50 is C1, I think it should be B5.

    Maybe one of the forums formula whizz-kids can shorten the formula a bit, but, unless I am missing something, I can't see how it can be done without sorting the data consistantly.

    I am assuming you are using 2003 as your file suggests, you don't say what version you are using in your profile.

    If you are using 2007 or above IFERROR() would simplify things.

    Hope this helps.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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