+ Reply to Thread
Results 1 to 4 of 4

Thread: Odd/Even Calculation

  1. #1
    Registered User
    Join Date
    11-10-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Odd/Even Calculation

    I needed some help trying to build a formula...

    say I have 3 columns, A, B, and C.

    I have the forum in C that: =B1*(RAND()*(0.95-0.85))

    But now if A1 = EVEN, I need to be sure that the result of that calculation (C1) is even, and if C1 isn't even, then add +0.01 to it so that it is.

    Is it possible to add this functionality into a formula that I can just plug into C1 and drag down as needed?

  2. #2
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,796

    Re: Odd/Even Calculation

    how are you determining even/odd? is 0.14754263
    considered odd? if so adding 0.01 wont make it even
    how many decimal places are you considering?
    =ROUND(B1*(RAND()*(0.95-0.85)),2) will narrow it down a bit
    Last edited by martindwilson; 11-10-2011 at 07:31 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057

    Re: Odd/Even Calculation

    Perhaps try a formula like this

    =CEILING(ROUND(B1*RAND()/10,2),((A1="EVEN")+1)/100)

    If A1 is EVEN then the result will be divisble by 0.02, if not then it may not be....

    format to 2 decimal places
    Audere est facere

  4. #4
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,796

    Re: Odd/Even Calculation

    or
    =IF(AND(ISEVEN(A1),ISODD(100*ROUND(B1*(E1*(0.95-0.85)),2))),ROUND(B1*(E1*(0.95-0.85)),2)+0.01,ROUND(B1*(E1*(0.95-0.85)),2)) where e1 contains rand()
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

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