+ Reply to Thread
Results 1 to 20 of 20

Can I nest an IF in a VLOOKUP?

Hybrid View

  1. #1
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Can I nest an IF in a VLOOKUP?

    Hi,

    I would like to know if I can nest an IF formula in a VLOOKUP. I have had two very nice people give me solutions BUT the solutions are not nesting an IF in my VLOOKUP. My VLOOKUP worked but I can not figure out how to make the IF work with it. I keep getting a VALUE error. Column I has "Date Shipped", I would like to use the 03/01/2013 format here. Column J has "Additional Shipping Costs", this is where I want to use my VLOOKUP to look on sheet 2 at a table named DOW(Day of Week). I got this far but what I can not make work is the IF it is Thurs-Sun than add Cell F14 (Cost of extra shipping for Thurs-Sun) + F15+F16. IF Mon-Wed than only add cells F15 +F16. I would greatly appreciate if someone could tell me if this is even possible or to look at my attempts on the workbook and see what I am doing wrong with my IF part.
    Thanks

    Original Post below-----


    Hi,
    I am learning excel and have a project I am working on that I need help with. I have "Date Shipped", in Column I. In Column J, I have Additional Shipping Costs. I have a table on Sheet 2 that is named DOW (Days of Week). 1=Sunday, 2=Monday, etc. I have an additional chart on Sheet 1 that explains the potential additional costs for shipping, i.e. blue ice =$5, box =$5, shipping Thursday through Sunday is an additional $10. In cell J2 I have a formula, (that worked to my amazement) it is =VLOOKUP(WEEKDAY(I2),DOW,2,FALSE) I wanted it to look at the date in I2, reference my DOW table, column 2 which is the day of the week, and give me the day of the week. It worked!!! Now the problem. I am wondering how or if I can nest another function in there that if the day of the week is Thurs, Fri, Sat, or Sun, it will reference cell F14 which is the additional fee $10 for shipping on those days, plus cells G14 and H14 for $5 for other shipping costs. If it is not Thurs-Sun then I would like it to just include shipping for G14 and H14. Is this possible? When I try the if function the info I put in seems to be fine until I hit ok then it wants I get an error or it wants to correct it and if I let it and I get an error anyway. I hope this is not too confusing. I am not sure if my attachment which has a screen print of my data made it but if it did maybe that will help to visualize. You cannot see the DOW table on sheet 2 but that should be ok. Can anyone help? I would greatly appreciate it.
    Attached Files Attached Files
    Last edited by Anjin; 08-05-2012 at 11:14 PM.

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: Nest an IF with a VLOOK

    Welcome to the forum Anjin.

    if you could post a real "workbook" other's surely will help.
    Sometimes we don't want to duplicate/retype your data.

    thanks.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Forum Contributor CheshireCat's Avatar
    Join Date
    10-11-2011
    Location
    Victoria, Canada
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    258

    Re: Nest an IF with a VLOOK

    Hi Anjin,

    This forum also allows you to attach a workbook so we can see what you're actually dealing with rather relying on a photo.
    Docendo discimus.

  4. #4
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Nest an IF with a VLOOK

    Ok,

    It is kind of messy right now because I have been playing with it. I do have personal addresses in there so I will delete those and attach it. I am new, this is my first post, how do I go back and attach to my original post?

  5. #5
    Forum Contributor CheshireCat's Avatar
    Join Date
    10-11-2011
    Location
    Victoria, Canada
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    258

    Re: Nest an IF with a VLOOK

    You can attach it to any post.

  6. #6
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Nest an IF with a VLOOK

    Ok,

    I think I just attached it to the original post.

    ---------- Post added at 11:39 PM ---------- Previous post was at 11:22 PM ----------

    Ok,

    I just realized that I had macros enabled so I don't want to scare anyone. I just resaved it as a regular file and will post the workbook again.
    Sorry all!

  7. #7
    Forum Contributor CheshireCat's Avatar
    Join Date
    10-11-2011
    Location
    Victoria, Canada
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    258

    Re: Nest an IF with a VLOOK

    The DOW table isn't required.

    Have a look at the attached.


    Anjin 2012-08-05.xlsx

  8. #8
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Nest an IF with a VLOOK

    Thanks Chesire,

    I appreciate that it works but I am not getting how. What is this (I13,2)>3,1,0) saying?? If I wanted to use the VLOOKUP can I use it in the formula?

    ---------- Post added at 12:48 PM ---------- Previous post was at 10:53 AM ----------

    Hi,

    I would like to use a VLOOKUP with an IF function if possible. I will reattach my workbook, "Salmon" and I will also reattach a solution workbook, "Anjin" a very nice person gave me. The problem with the solution is that it does not use my VLOOKUP which I am trying to learn how to use. My VLOOKUP worked but I cannot figure out how to make the IF work with it. Column I has "Date Shipped", I would like to use the 03/01/2013 format here. Column J has "Additional Shipping Costs", this is where I use my VLOOKUP to look on sheet 2 at a table named DOW(Day of Week). I got this far but what I cannot make work is ---IF it is Thurs-Sun than add Cell F14 (Cost of extra shipping for Thurs-Sun) + F15+F16. IF Mon-Wed than only add cells F15 +F16. You can see my attemps and the VALUE errors. Cheshire's solution was =IF(WEEKDAY(I13,2)>3,1,0)*$F$14+$F$15+$F$16. I don't understand the ,2)>3,1,0) part of this formula could someone explain this also

  9. #9
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Nest an IF with a VLOOK

    You other question is called solved.

    You i get lost of all my text.

    Here my example.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  10. #10
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Nest an IF with a VLOOK

    Thanks BUT,

    Great solution to add the shipping costs to my DOW table BUT it is not really doing what I am trying to do which is to use a VLOOKUP and reference the cells on sheet 1 with an IF function. I am trying to see if I can nest an IF in a VLOOKUP, I want to learn how to do this. I have two solutions that both work but technically the solutions are not addressing what I am really trying to understand and learn how to do. I am going to leave this open to see if someone can tell me how or if I can do this.
    Thanks though--

    ---------- Post added at 01:16 PM ---------- Previous post was at 01:14 PM ----------

    Thanks for explaining that, could I somehow nest this formula into my VLOOKUP. What I am trying to learn is how to nest functions with a VLOOKUP.

    ---------- Post added at 01:16 PM ---------- Previous post was at 01:16 PM ----------

    Thanks for explaining that, could I somehow nest this formula into my VLOOKUP. What I am trying to learn is how to nest functions with a VLOOKUP

  11. #11
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Nest an IF with a VLOOK

    Yes this is possible, see my example (with the formula below).

    +H2+VLookup(VLookup(WEEKDAY($I2),DOW,2,ONWAAR),DOW[[Column2]:[price]],2,0)
    1) VLookup(WEEKDAY($I2),DOW,2,ONWAAR) will give as result the weekday.

    This result I used for the second Vlookup.

    2) VLookup(sunday,DOW[[Column2]:[price]],2,0)

    This result gives the price in the table.

    I hope I explained it well enough.

  12. #12
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Nest an IF with a VLOOK

    I am pretty new to excel so I am learning how to read these formulas. It does not appear that your VLOOKUP formula has a nested "IF" function referencing cells F14,F15,F16 on sheet one. My whole experiment is to nest an IF in a VLOOKUP if that is even possible. But thanks for taking your time to help me.

  13. #13
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Nest an IF with a VLOOK

    Indeath it's not an nested "IF"function.

    But, it realy is an nested function.

  14. #14
    Forum Contributor CheshireCat's Avatar
    Join Date
    10-11-2011
    Location
    Victoria, Canada
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    258

    Re: Nest an IF with a VLOOK

    The WEEKDAY function gives you options on how to number the days of the week (see Excel help for an explanation). The second option (the "2" in the function) gives you this:

    1 Mon
    2 Tue
    3 Wed
    4 Thu
    5 Fri
    6 Sat
    7 Sun

    So in my formula:

    WEEKDAY(I13,2)

    will give a 3 or less if the day is Mon - Wed, and 4 or greater if it is Thu - Sun.

    In the IF function

    IF(WEEKDAY(I13,2)>3,1,0)

    will give a "1" if the day of the week is Thu - Sun and a "0" if it isn't. I then multiply that by F14 to add the shipping charge.

    The DOW table and the VLOOKUP function is not required.

  15. #15
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Nest an IF with a VLOOK

    Oeldere,

    The name of my post is nested IF with VLOOKUP. This is the point of what I am trying to do. Is it possible to nest an IF in a VLOOKUP and if so can it be done with my information. If it can't be done I will stop trying to do it. Your nested formula works but again it is not addressing what I want to do. Thanks again for your info though---

  16. #16
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Nest an IF with a VLOOK

    Yes this is possible (Nest an IF with a VLOOK)


    =If(VLookup(WEEKDAy(I14),Sheet2!$A$2:$B$8,2,0)="Monday",15,12)


    And now you get a second question

    Yes this is possible (Nest an IF in a VLOOK)

    =VLookup(If(J16=2;2;4),Sheet2!$A$2:$B$8,2,0)
    Last edited by oeldere; 08-05-2012 at 06:22 PM. Reason: And now you get a second question

  17. #17
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Can I nest an IF in a VLOOKUP?

    I have tried a million combinations and nothing works. I have looked all over just asking the simple question, can you nest an IF in a VLOOKUP, no one seems to have a strait forward answer for this. The basic question requires a YES or NO, can it be done? If I knew whether it was possible or not I would know whether I should bother or pack it in.

    ---------- Post added at 08:26 PM ---------- Previous post was at 08:09 PM ----------

    Oeldere,

    I feel foolish, I am not quite getting how the forum works. I just joined yesterday. I did not see your post until just now after I just added another post to my post and then just your last post popped up. I have tried clicking on my posts but that only worked once for me, I just keep going back and see if there are more numbers on the post, it is a little confusing but I will catch on. SO IT IS POSSIBLE ---I thank you so much for your help!!! I will try to get better at asking questions and not posting and reposting. I got a couple hand slaps for trying to repost and wording my question different ways, I was not sure if it was too confusing or if I should have put the question in the basics forum. Please forgive my ignorance, I am really enjoying excel and learning all the ways you can really make it sing. Thanks for your patience and help!

  18. #18
    Forum Contributor CheshireCat's Avatar
    Join Date
    10-11-2011
    Location
    Victoria, Canada
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    258

    Re: Can I nest an IF in a VLOOKUP?

    Anjin,

    To answer your question "Can I nest an IF in a VLOOKUP?" the answer is "Yes". oeldere has already provided two examples of how the syntax would look.

    The problem you seem to be experiencing is due to you trying to "force" that approach into an example where it simply does not fit. It must make sense to do it before you can or should do it.

    Hope this helps.

  19. #19
    Registered User
    Join Date
    08-05-2012
    Location
    Alaska, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Can I nest an IF in a VLOOKUP?

    Cheshire,

    See my post to Oeldere, Dito to you. Thanks for your patience and help!! I will go figure out how to close this post our.

  20. #20
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Can I nest an IF in a VLOOKUP?

    @anjin

    Don't feel foolish, we all had to learn by trying.

    I admire you perserverance.

    I agree with CheshireCat
    The problem you seem to be experiencing is due to you trying to "force" that approach into an example where it simply does not fit. It must make sense to do it before you can or should do it.
    For your problem are better alternatives.

    Just use them and learn of those options.

    Glad I could help. Thanks for the reply.

    If the question is solved, will you mark your question as solved?

    You can do this above the first question on the middle of the page (in small letters), the most left option.

    If you have (other) questions, just ask.

+ 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