+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    10-08-2007
    Posts
    3

    multiply cell value by a number dependent on two criteria

    if c1 says "x" and d1 says "y" then multiply a1 by 1

    if c1 says "x" and d1 says "l" then multiply a1 by 2

    i can get the first statement to work with the following function:

    =IF(C1="x",AND(D1="y")*A1*1)

    but i cant get it to multiply the content in a1 by a different number based on a different value in c1 and/or d1.

    any help is mucho appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    MS Office Excel 2007
    Posts
    698
    =IF(AND(C1="x",D1="y"),A1,IF(AND(C1="x",D1="l"),A1*2,"???"))

    You havent said what happens if C1 not equal "x" and D1 not equal "y" or "l" so I've put "???" instead
    Regards
    Special-K

    I rarely return to a problem once I've answered it so make sure you clearly define what the trouble is.

  3. #3
    Registered User
    Join Date
    10-08-2007
    Posts
    3
    mucho thankso... got me headed in right direction... not sure if i can do what i ultimately want...

    say c1 and d1 can have the values below, can one function contain all possibilities? (i.e. - 'x''y', 'x''l', 'x''r', 'b''y','b''l','b''r', etc.) with each condition met resulting in a certain number to multiply cell a1 by? i was able to add a third criteria successfully with the function below, but when i try to extend it using "b" as c1 value and continuing through the d1 values it says i have entered too many arguments for the function.

    maybe i had the function entered incorrectly, or perhaps i am asking too much from the program with so many variables in one function?

    i can always just use the function you provided on a worksheet that only contained "x" in the c1 cell and run through 3 variables of a d1 cell, then pull up a second worksheet that only contained "b" in c1 cell and run through the d1 variables,etc. etc. and combine end results, but it would save a few steps if it could all be included in one function.

    thx again for help provided.


    c1 = x,b,c,d

    d1 = y,l,r

    =IF(AND(C1="x",D1="y"),A1,IF(AND(C1="x",D1="l"),A1*2,IF(AND(C1="x",D1="r"),A1*3)))


    edit: this is the function i proposed that resulted in "too many arguments" error

    =IF(AND(C1="x",D1="y"),A1,IF(AND(C1="x",D1="l"),A1*2,IF(AND(C1="x",D1="r"),A1*3),IF(AND(c1="b",d1="y "),a1*4))))
    Last edited by podium123456; 10-08-2007 at 11:53 PM.

  4. #4
    Registered User
    Join Date
    10-08-2007
    Posts
    3
    one last bump to see if anyone else has a solution. if not, thx for the help provided.

  5. #5
    Forum Moderator NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003, 2007, 2010
    Posts
    31,163
    I propose you create a small side table consisting of 2 columns. The first column would display all the combinations of C1&D1 combined. The second would show the corresponding multiplication factor.

    Then you could use a simple formula such as:

    =A1*Vlookup(C1&D1,X1:Y20,2,0)

    Where X1:Y20 would be your lookup table you created. Adjust as necessary.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

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.2.0