+ Reply to Thread
Results 1 to 8 of 8

Vlookup combined with IF function

  1. #1
    Registered User
    Join Date
    07-04-2013
    Location
    Hilversum
    MS-Off Ver
    Excel 2010
    Posts
    4

    Vlookup combined with IF function

    Hello everyone

    I am facing a rather odd issue with the Vlookup formula for which i need your assistance.


    I have 2 sheets in my workbook, "Factuur" for an invoice template and "Assortment" where i have a table with my products.



    The product table is sorted alphabetically with unique names and is arranged in the following way
    Column 1: Product Name
    Column 3: Price per unit if order quantity for this product is lower than 12 (VE=1)
    Column 4: Price per unit for 12 or more order quantity (VE=12)


    What i need is a formula which will return the price per unit based on the order quantity

    In my invoice sheet i used the following formula
    =VLOOKUP(G21;Assortiment!A1:E277;IF(D21<12;3;4))
    where
    G21 is the product name
    Assortiment!A1:E277 the table in the catalogue sheet
    D21 order quantity

    The problem: The price shown is correct when the order quantity cell is blank. As soon as i type a value i Always get the price VE=12 price, even if the order quantity is lower than 12.


    The strange thing is that EXACTLY the same formula works perfectly for all order quantities when used in the same sheet as with the catalogue. . So i am only getting this problem in the invoice sheet.


    Is there something that i am overlooking? And how can i fix this without having to combine invoice and catalogue in one sheet?

    Thank you beforehand
    Ioannis
    Last edited by Giannis86; 07-04-2013 at 01:07 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Vlookup combined with IF function

    You may need to add a 4th parameter to your Vlookup to tell Excel you want an exact match

    Try:

    =VLOOKUP(G21;Assortiment!A1:E277;IF(D21<12;3;4);0)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Vlookup combined with IF function

    Can you upload your workbook and indicate which cells show the wrong answer and what the answer should be.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    07-04-2013
    Location
    Hilversum
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Vlookup combined with IF function

    Quote Originally Posted by NBVC View Post
    You may need to add a 4th parameter to your Vlookup to tell Excel you want an exact match

    Try:

    =VLOOKUP(G21;Assortiment!A1:E277;IF(D21<12;3;4);0)
    Thank you but unfortunately that makes no change

    Quote Originally Posted by Richard Buttrey View Post
    Can you upload your workbook and indicate which cells show the wrong answer and what the answer should be.
    Sure, i will highlight the cells and upload the file in a minute

  5. #5
    Registered User
    Join Date
    07-04-2013
    Location
    Hilversum
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Vlookup combined with IF function

    Hereby the file. I highlighted the cells you should be looking at

    Thank you for the help so far
    Attached Files Attached Files

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Vlookup combined with IF function

    Your column D values are text not numbers... you will need to account for that in your formula:

    =VLOOKUP(G21;Assortiment!A1:E277;IF(D21+0<12;3;4);0)

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Vlookup combined with IF function

    Hi,

    Your column D quantities are text (which happen to look like numbers) whereas you're returning a column Number for the function.

    Try
    =VLOOKUP(G22,ASSORTIMENT,IF(D22*1<12,3,4),0)

    Ideally you should always ensure the two values you're using are both text or both numbers.

  8. #8
    Registered User
    Join Date
    07-04-2013
    Location
    Hilversum
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Vlookup combined with IF function

    Wow didn't see that, thanks!

    Works perfect now!

+ 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