+ Reply to Thread
Results 1 to 9 of 9

Random selection of cell information from a group of cells

  1. #1
    Registered User
    Join Date
    04-27-2009
    Location
    Somewhere, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    11

    Random selection of cell information from a group of cells

    I am working with Excel 2007.

    In my spread sheet I have:

    l A l 001 l
    ------l 002 l
    ------l 003 l

    This means "A" is equal to "001", "002", or "003". It does not matter which.

    I want that whenever I type "A" into a cell, that "A" is changed to either "001", "002", or "003". I want it to change randomly between the three options so that"A" is not always "002", or whichever.

    I want the formula to say: IF "A", then randomly change to "001", "002", or "003".

  2. #2
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Re: Random selection of cell information from a group of cells

    Hi,

    You could try this in B1

    =IF(A1="","",IF(A1="A",RANDBETWEEN(1,3),""))

    Then custom format B1 to 000
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  3. #3
    Registered User
    Join Date
    04-27-2009
    Location
    Somewhere, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    11

    Re: Random selection of cell information from a group of cells

    Alright, I've figured this much out.

    =IF(S1="A",INDEX(R1:R2,RANDBETWEEN(1,COUNTA(R1,R2)),1))

    Now, if "A" is found in cell S1 the formula will randomly pick between posting the information from cells R1 and R2. If there is no "A" the formula returns "FALSE". Good.

    The next problem is how do I tack on other formulas in that cell. The letter "A" is covered. Now I want that same cell to look to find "B", "C", etc and, if found choose randomly from their respective pools of possible representative numbers.

    So that, if I type "A" in S1 I get either 001 or 002.
    If I type "B" in S1 I get 003, 004, or 005.
    If I type "C" in S1 I get 006, 007, 008, or 009.
    etc
    etc

    How do I make that happen?

  4. #4
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Re: Random selection of cell information from a group of cells

    Does each additional letter randomly select another additional digit?

    For example D could be 010 to 014?

  5. #5
    Registered User
    Join Date
    04-27-2009
    Location
    Somewhere, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    11

    Re: Random selection of cell information from a group of cells

    Yes.
    I have attached an example of what should happen, I hope this helps you help me.

    However, the numbers that go along with the letters are not really sequential as shown in my example.
    The true numbers are more like:

    A=1919191
    1919201
    1233212

    B=0000000011
    0000001100
    0000000110

    an so on with random sequences.
    Attached Files Attached Files
    Last edited by Icecycle66; 07-22-2009 at 01:49 PM. Reason: Clarification

  6. #6
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Re: Random selection of cell information from a group of cells

    Hi,

    Does this help? I've used this formula in E1 and custom formatted the cell to 000

    =RANDBETWEEN(VLOOKUP(D1,$A$1:$B$21,2,FALSE)+0,VLOOKUP(D1,$A$1:$B$21,2,FALSE)+0+2)

  7. #7
    Registered User
    Join Date
    04-27-2009
    Location
    Somewhere, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    11

    Re: Random selection of cell information from a group of cells

    The formula works properly, as it is written.

    However, I don't think I have expressed properly what I need.
    Attached is a copy of the worksheet.
    The possible numbers of a letter which they represent are set. (Columns "A" and "B"). In column "D" I type one letter and in column "E" one of the choices of letter representation is choosen and displayed at random.

    The Formula you have provided works well, but it changes the number available to represent the letter by adding "1" or "2"; somehow.

    Also, I can't seem to get the format of "00000000 000" to display, all I get is #value!. Even after changing custom and standard formats.
    Attached Files Attached Files

  8. #8
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Re: Random selection of cell information from a group of cells

    Hi,

    Well I must admit I'm stumped

    I can see you posted your original question in the Programming Forum and now that I've seen your spreadsheet that's the best place for it. When I first saw your original question I throught I could do it with formulas.

    I suggest that you post again in programming, but under a new title and attaching your last spreadsheet, but you could also provide a link to this thread as well so that they can see not to do anything like I did.

    Sorry I can't help, only VBA is not my expertise - good luck

  9. #9
    Registered User
    Join Date
    04-27-2009
    Location
    Somewhere, USA
    MS-Off Ver
    Excel 2003/2007
    Posts
    11

    Re: Random selection of cell information from a group of cells

    Last edited by Icecycle66; 07-23-2009 at 11:35 AM.

+ 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.6.0 RC 1