+ Reply to Thread
Results 1 to 7 of 7

Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

  1. #1
    Registered User
    Join Date
    07-26-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2003
    Posts
    8

    Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

    I need a help.

    I need to generate a spreadsheet with many numbers from -1.5 to 1.5.

    The numbers must have 2 decimal numbers, ie: 1.48; -0.74; -0.22; 1.23;...

    But no zeros must appears and the formula must work on Excel 2003.

    • 2 decimal numbers
    • Excel 2003
    • No zeros must appears

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

    =if(int(2*rand()+1)=1,-1,1)*round(9*rand()+1,2)

    ---------- Post added at 02:15 PM ---------- Previous post was at 01:08 PM ----------

    oops....
    =ROUND(IF(INT(2*RAND()+1)=2,1,-1)*(1.5*RAND()),2)
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,006

    Re: Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

    Or this: =(RAND()+1/100)*(1.5-1/100)*SIGN(RAND()-0.5)
    Last edited by zbor; 08-01-2012 at 03:51 AM.
    Never use Merged Cells in Excel

  4. #4
    Registered User
    Join Date
    07-26-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

    Thanks! It is working very well!

    To my colleagues in Brazil, the same formula in Excel in Portuguese-BR is:

    =ARRED(SE(INT(2*ALEATÓRIO()+1)=2;1;-1)*(1,5*ALEATÓRIO());2)

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

    @ Megadementia

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

    Quote Originally Posted by tlafferty View Post
    =ROUND(IF(INT(2*RAND()+1)=2,1,-1)*(1.5*RAND()),2)
    I don't believe this fulfils the criteria, RAND() can generate zero and very low values of RAND(), rounded to two decimal places, will generate more zeroes. Try entering the formula in 10,000 rows, you'll get 30+ zeroes

    ......also you won't get an absolutely even distribution because of use of the ROUND function, that means the values on the extremity (1.5 and -1.5) can happen but will occur on average half as often as other values.

    This version should give you an even distribution with no zeroes

    =IF(RAND()< 0.5,1,-1)*INT(150*RAND()+1)/100
    Audere est facere

  7. #7
    Registered User
    Join Date
    07-26-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Random non-int numbers from -1.5 to 1.5 w/o zero in Excel 2003

    Roger that! Beg your pardon!

    Quote Originally Posted by Cutter View Post
    @ Megadementia

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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