+ Reply to Thread
Results 1 to 3 of 3

Thread: RANDBETWEEN Does Not Accept a letter variable

  1. #1
    Registered User
    Join Date
    02-03-2012
    Location
    Slippery Rock, PA, USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Question RANDBETWEEN Does Not Accept a letter variable

    I am trying to generate a random number between 2 and an integer inputed by the user through an InputBox which I call say 'k'. The code
    ActiveCell.FormulaR1C1 = "=RANDBETWEEN(2, k)" does not work. It works only if I replace k by an integer greater than 2. I have checked that The variable k does equal the integer provided by the user. Thanks for the help

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: RANDBETWEEN Does Not Accept a letter variable

    Welcome to the forum.

    Post your code.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Excel 2007
    Posts
    686

    Re: RANDBETWEEN Does Not Accept a letter variable

    Try it like this:

    ActiveCell.FormulaR1C1 = "=RANDBETWEEN(2," & k & ")"

    Hope this helps.

    Pete

+ 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