+ Reply to Thread
Results 1 to 12 of 12

If function to return no. based on 2 cells?

  1. #1
    Registered User
    Join Date
    07-17-2007
    Posts
    15

    If function to return no. based on 2 cells?

    Hi everyone,

    I need help on using the If function. Basically I am trying to calculate the cost of shipments. For example, cost of sending 1 box is 150 (eg cell A3), 2 boxes is 280 (cell A4), 3 boxes is 400 (A5), 4 boxes is 500, etc upto to 10 boxes (cell A12).

    What I am looking for is cell A1 to provide me the cost based on the manually entered value of cell A2, i.e. if I enter a number between 1 to 10 in cell A2, then A1 should return a number from A3 to A12, e.g. enter 3 in A2 then A1 should return 400.

    Is there such a formula or do I have to enter manually the amounts into an If function?

    Thanks guys an gals!
    Last edited by duffer; 10-15-2008 at 08:54 AM. Reason: solved

  2. #2
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    Suggest you use a Lookup or Vlookup function

    see the attached example of VLOOKUP or this for lookup

    http://www.techonthenet.com/excel/formulas/lookup.php
    Attached Files Attached Files
    Ed
    _____________________________
    Always learning, but never enough!
    _____________________________

  3. #3
    Registered User
    Join Date
    07-17-2007
    Posts
    15
    Quote Originally Posted by EdMac View Post
    Suggest you use a Lookup or Vlookup function

    see the attached example of VLOOKUP or this for lookup

    http://www.techonthenet.com/excel/formulas/lookup.php
    Hi Edmac,

    It gets more complicated... This is formula (=SE is =IF in Italian) I am using:

    =SE(E4=0;"0,00";SE(E4=1;"128,10";SE(E4=2;"155,10";SE(E4=3;"222,60";SE(E4=4;"263,00";SE(E4=5;"333,90";SE(E4=6;"371,00";SE(E4=7;"438,40";SE(E4=8;"492,40";SE(E4=9;"546,30";SE(E4=10;"607,00")))))))))))

    My problem is that these are the prices for 1 post code and I have about 10 post codes in total, therefore I need to have 10 different formulae.

    Would Lookup help me in this case??

  4. #4
    Valued Forum Contributor ratcat's Avatar
    Join Date
    03-07-2008
    Location
    Rural NSW, Australia
    MS-Off Ver
    Vista 2007
    Posts
    1,111
    G'day duffer,

    Could you supply an example of your data layout.

    But I'm have problems picturing the layout you are using.

    I have an idea of using a dynamic lookup.

    Thanks
    Have I made you happy ??? If yes, please make me happy by pressing the http://www.excelforum.com/images/buttons/reputation-40b.png Add Reputation button in my post.
    Please don't forget to do the same to other contributors of this forum.

    Thanks
    I don't void confusion, I create it

  5. #5
    Registered User
    Join Date
    07-17-2007
    Posts
    15
    Ciao,

    Thanks. Please find attached an example of what I'm trying to do. I've done the formula for the first and last row because they have the same price.

    Now imagine if I am doing this for every week and there are 10 or more different prices.

    I don't have experience of Vlookup but if it would work then that would be purrrfect!

    I am using an Italian package therefore we use ; instead of , to seperate the functions.

    Thanks!
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor ratcat's Avatar
    Join Date
    03-07-2008
    Location
    Rural NSW, Australia
    MS-Off Ver
    Vista 2007
    Posts
    1,111
    G'day duffer,

    Too your layout the Vlookup is no good. Different layout sometimes needs different formulas

    But the Index and a nesting Match formula works beautifully.

    Cell B4
    Please Login or Register  to view this content.
    This formula has a IF statement wrap to return a blank cell
    Please Login or Register  to view this content.
    See attached. xl should change the , to ; for you in the formulas

    Attached is a xl 97-2003 version.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    05-21-2004
    Location
    UK
    Posts
    136
    Try this

    =IF(OR(C4<0,C4>10),0,CHOOSE(C4+1,0,128.1,155.1,222.6,263,333.9,371,438.4,492.4,546.3,607))

  8. #8
    Registered User
    Join Date
    07-17-2007
    Posts
    15
    Ciao ratcat,
    I think this could be purrrfect!
    As Colombo would say 'just one more thing': In the example there are 5 weeks, but if I needed to show for 52 weeks, how can I copy the formula across without the range being shifted, i.e. the formula chooses the correct cell for each week but chooses the incorrect range - it should always be $N4:$X4,MATCH(C4,$N$2:$X$2 ??

    Thanks for this. It's been bugging me as I thought I would have to manually enter each formula and I've been trying to put it off for days now.

    I hope you have a g'day!

  9. #9
    Valued Forum Contributor ratcat's Avatar
    Join Date
    03-07-2008
    Location
    Rural NSW, Australia
    MS-Off Ver
    Vista 2007
    Posts
    1,111
    Well duffer.....

    The "$" symbol tells xl to make the cell stay put at that reference.
    Practice on a blank, sheet very basic formulas on different combinations when copying the formula at different place on the spreadsheet.
    Click and drag on the node on the edit box (located on the bottom right hand of box).

    Click here for further info

    With your spreadsheet

    What I did was type the cell out in C4 then copy down
    then with that cell range highlighted I copy (Ctrl C) the range
    then move the edit box to the next cell (D4) and paste (Ctrl V)
    then move to the next cell (F4) and etc etc and etc.

    So if you get cell reference right, you only type once.

    Cheers

  10. #10
    Registered User
    Join Date
    07-17-2007
    Posts
    15
    Fantastic you are my god!

  11. #11
    Registered User
    Join Date
    07-17-2007
    Posts
    15

    Thumbs up

    Quote Originally Posted by xld View Post
    Try this

    =IF(OR(C4<0,C4>10),0,CHOOSE(C4+1,0,128.1,155.1,222.6,263,333.9,371,438.4,492.4,546.3,607))
    thanks xld, it sure is better than my attempt. i do prefer the function ratcat provided as it's easier to manage should there be additional prices, price changes, more postal areas to add at a later date. ciao for now, duffer.

  12. #12
    Forum Contributor
    Join Date
    05-21-2004
    Location
    UK
    Posts
    136
    No problem, just keep it in your back pocket for the next time :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Return a reference from LARGE function
    By marcusmpe in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-15-2017, 03:28 AM
  2. Replies: 3
    Last Post: 11-22-2007, 07:53 AM
  3. Grouping cells based on their contents
    By mmuise in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-21-2007, 04:58 PM
  4. writing a formula to return non-empty cells
    By pmetzak in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-18-2007, 03:34 PM
  5. Return value from a function
    By cgi_pro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2006, 06:28 AM

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