+ Reply to Thread
Results 1 to 7 of 7

Vlookup

  1. #1
    Registered User
    Join Date
    10-31-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    4

    Vlookup

    For the problem presented below I am thinking of using multiple formulas from the lookup "family" but I am not sure if this can actually be done. If someone could give me an idea of how to do this it would be great.
    It might be that this cannot be done without VBA, but before abandoning I thought I should ask more knowledgeable users of Excel formulas.

    The problem:
    In sheet1 I have the quantities sold from different products, the client buying them, and the date of the sale.

    In sheet2 I have the prices of said products, each different according to the client that buys them. To add another level of complexity, the prices change in time, according to agreements that cover certain periods.

    I need to calculate the value of each sale (that most often includes a number of different products) and for that I need the correct sale price for each of those products. Therefore I need to look in sheet1 at the date of the sale, and then look in sheet2 to see, for each product, where does that particular date fit between "start date" and "end date" (ie, what negotiated prices apply to that particular sale).

    I don't know if I have managed to present this in a way that makes enough sense, so I have attached a sample file.

    For example, in sheet1!R3 there should be a value of 800, because in "October 6" we sold to client "E"

    "1" item of "prod1" at the price of "200" (because, given the sale date, the correct price is the one from the agreement starting in October 5 and ending in October 20)
    +
    "2" items of "prod3" sold to client "E" at the price of "300" each.

    Another example:

    In sheet1!R10 the value should be 2100 because in "October 24" we sold to the same client E

    "1" item of "prod3" at the price of "900" (as seen in sheet2!F9 - because the agreement that applies for that sale date is the one starting October 21 and ending October 24)
    +
    "3" items of "prod7" at the price of "400" each.

    For easy following of the examples, I highlighted the involved numbers in the 2 sheets.

    I have constructed sheet2 in a way it makes sense to me. It may be that it can be structured in a better way. Sheet1 however cannot change structure.

    Thanks a lot for any help you are able to give!
    Attached Files Attached Files
    Last edited by ild12; 10-31-2009 at 02:54 PM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,604

    Re: Possible complex application of vlookup

    How about this:

    problem(1).xls

  3. #3
    Registered User
    Join Date
    10-31-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Vlookup

    I need to fill the "value of sale" column in sheet1. The pivot table you propose does a sum of the prices for each product and client, but I don't need that. I need the correct connection between quantities and prices from the two sheets... and I need it done (if at all possible) in that column R of sheet1.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Vlookup

    Based on your first post and expected outcomes perhaps:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-31-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Vlookup

    Thanx DonkeyOte. It does seem to handle ok everything related to client E.
    However, as you can see from some examples highlighted in red in this new attachment, the sale value is not calculated correctly for other clients.

    I will try to modify the formula myself, but sincerely I don't understand yet how it works. Thanx again for pushing me to the right direction though.
    Attached Files Attached Files
    Last edited by ild12; 10-31-2009 at 05:40 PM.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Vlookup

    It is my error.

    If you look at the formula in R3 ... the very last reference to B3 should read as $B3 and not $B$3 as it did in my example.

    (essentially using $B$3 means it is always looking for client as specified in B3 in each and every other row whereas the client should "adapt")

  7. #7
    Registered User
    Join Date
    10-31-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Vlookup

    Bless you! Everything seems to work ok now.

    I will further test it tomorrow to see if it handles ok the insertion of new clients/products/agreements and report the results.

+ 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