+ Reply to Thread
Results 1 to 4 of 4

Excel nested IF function

  1. #1
    Registered User
    Join Date
    05-04-2008
    Posts
    2

    Excel nested IF function

    Ive got a workbook to keep a diet journal that lets me put in a reference number and the quantity of a particular food and up pops all the nutritional info and calculates daily values. Screenshot


    Using the following function I am limited to 8 items:
    =C27*IF(B27=1,$F$2,IF(B27=2,$F$3,IF(B27=3,$F$4,IF(B27=4,$F$5,IF(B27=5,$F$6,IF(B27=6,$F$7,IF(B27=7,$F$8,IF(B27=8,$F$9,0))))))))

    Is there anyway i can extend this to give me a larger number of IF's or another function i can use to accomplish teh same result?

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

    =C27*INDEX($F$2:$F$9,B27)

    adjust the F2:F9 range to suit.
    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 Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    =C27*INDIRECT("F"&CHOOSE(B27,2,3,4,5,6,7,8))
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    05-04-2008
    Posts
    2
    Quote Originally Posted by NBVC
    How about:

    =C27*INDEX($F$2:$F$9,B27)

    adjust the F2:F9 range to suit.

    That did it!!! thank you for the quick response.

+ 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