+ Reply to Thread
Results 1 to 8 of 8

IF Function Help

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2007
    Posts
    10

    IF Function Help

    I am a novice...and a bit thick.

    I have written an IF Function;

    =IF(A2>=1,RANDBETWEEN(1,9),)

    It returns a value between 1 and 9 if A2 is 1, which great and exactly what I need. However, when A2 is 0, I need there to be no change.

    Do I even need to use an IF function?

    Basicallly if A2 = 1 then I need it to produce a random number between 1 and 9.
    if A2 = 0 then I need it to stay the same, or repeat the previous value.

    Any help would be greatly appreciated.

  2. #2
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Moscow
    MS-Off Ver
    Excel 2010
    Posts
    291

    Re: IF Function Help

    If all your values in A column, then put in B column your If function as =IF(A2>=1,RANDBETWEEN(1,9),A2). After you can copy B column and past it special as values. Is it acceptable for you?

  3. #3
    Registered User
    Join Date
    05-15-2012
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: IF Function Help

    Thanks for your reply, but I think that would just return a 1 or a 0. I need to return the previous random number. For example;

    A2=1 Random number = 6
    A2=1 Random number = 3
    A2=1 Random number = 4
    A2=0 number = 4
    A2=0 number = 4
    A2=1 Random number = 9
    A2=0 number = 9
    etc
    etc
    etc

    I hope that makes it clearer and doesn't complicate things :/

    Thanks

  4. #4
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Moscow
    MS-Off Ver
    Excel 2010
    Posts
    291

    Re: IF Function Help

    ok i see....

  5. #5
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Moscow
    MS-Off Ver
    Excel 2010
    Posts
    291

    Re: IF Function Help

    B2: =IF(A2>=1,RANDBETWEEN(1,9),B1) and drag down

  6. #6
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: IF Function Help

    =IF(A1>=1,RANDBETWEEN(1,9),B1)

    Above goes in B1. Unfortunately, my solution requires enabling circular reference
    Regards,
    Vandan

  7. #7
    Registered User
    Join Date
    05-15-2012
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: IF Function Help

    I don't quite understand?
    Basically A2 returns Value 1 or 0. When it does B2 either produces a random number, or repeats the previous number.

    I think one way to solve it may be to create a descending log of all the numbers B2 produces, in C2. Then using that I can use the formula =IF(A2>=1,RANDBETWEEN(1,9),C2)

    Do you know how to create a descending log of numbers by any chance? To have the log would be a handy data source as well.

    Thanks for all your help.

  8. #8
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Moscow
    MS-Off Ver
    Excel 2010
    Posts
    291

    Re: IF Function Help

    Is not that what you wanted?
    Attached Files Attached Files
    Last edited by Alexander_Golinsky; 05-15-2012 at 02:46 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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