+ Reply to Thread
Results 1 to 17 of 17

Selecting Multiple Random Variables From A Row

  1. #1
    Registered User
    Join Date
    09-19-2017
    Location
    germany
    MS-Off Ver
    1707
    Posts
    7

    Selecting Multiple Random Variables From A Row

    Hi everybody i have the following problem, which I tried to figure out for the last hour or so. I believe their must be an easy solution but i somehow i cant figure it out. But i am sure you can help!

    I have a column with the numbers from 1 to 5

    Row A:
    1
    2
    3
    4
    5

    In Cell B1 I have the formula for choosing a random cell from Row A:
    =INDEX(A1:A5,RANDBETWEEN(1,5))


    Now to the Problem:
    I want to make a string adding to of the randomly chosen numbers behind each other.

    However, when I try to use the following:
    =B1&B1

    The chosen number will be the same and I only get results like 11, 22, 33, 44 or 55

    How can I tell excel to recalculate the value from cell B1 so that I can get numbers like 12, 43, 52 ec.


    I can achieve it with
    =INDEX(A1:A5,RANDBETWEEN(1,5))&INDEX(A1:A5,RANDBETWEEN(1,5))
    However it is really complicate to keep an overview of the formula in one cell as my actual choosing selection and string is a bit mor complicated
    Last edited by The Cookie Monster; 09-19-2017 at 09:07 AM.

  2. #2
    Forum Contributor shivya's Avatar
    Join Date
    08-19-2017
    Location
    Delhi, India
    MS-Off Ver
    2013
    Posts
    240

    Re: I thought this would be easy

    Hello Cookie Monster,
    would you please attach a sample file or screenshot and please mention your desired result as well.
    Last edited by shivya; 09-19-2017 at 06:34 AM. Reason: forgot to mention something

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: I thought this would be easy

    I doubt this is possible without VBA. If you want to simplify the formula, you could put the second Randbewteen in a third column

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: I thought this would be easy

    Doesn't this do it:

    =INDEX($A$1:$A$5,RANDBETWEEN(1,5))&INDEX($A$1:$A$5,RANDBETWEEN(1,5))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: I thought this would be easy

    Yes, he put that in the question, but thinks the formula is unwieldy.

    You could do it like this in VBA:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-19-2017
    Location
    germany
    MS-Off Ver
    1707
    Posts
    7

    Re: I thought this would be easy

    Actually I want to automatically generate messanges like the following:

    You can choose between VAR1 and VAR1. We also have VAR2

    Row A contains
    VAR1a
    VAR1b
    VAR1c

    Row B contains
    VAR2a
    VAR2b
    VAR2c

    Will it be difficult if I do it with VBA?


    =INDEX($A$1:$A$5,RANDBETWEEN(1,5))&INDEX($A$1:$A$5,RANDBETWEEN(1,5))
    Does work, but I loose the overview of what I am doing in big messanges...

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: I thought this would be easy

    Sorry, I've no idea what your last message means - I don't understand what you are trying to do

  8. #8
    Registered User
    Join Date
    09-19-2017
    Location
    germany
    MS-Off Ver
    1707
    Posts
    7

    Re: I thought this would be easy

    Thank you for posting the VBA Code. I have never worked with VBA before so I dont really know what to do with it? Can you explain or tell me what I have to look for if i want to set it up!

    And thank you so much for your quick help!

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: I thought this would be easy

    I doubt it will do what you want based on your actual requirement. Please upload a workbook with representative data

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: I thought this would be easy

    Quote Originally Posted by Kyle123 View Post
    Yes, he put that in the question, but thinks the formula is unwieldy.
    Lol. Didn't read that bit.... (S)He should rootle around here for a while and see what an unwieldy formula REALLY looks like!!

  11. #11
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: I thought this would be easy

    I know, there are some real monsters, makes me wish for a better way of laying them out. They're always easier to write than read

  12. #12
    Registered User
    Join Date
    09-19-2017
    Location
    germany
    MS-Off Ver
    1707
    Posts
    7

    Re: I thought this would be easy


  13. #13
    Registered User
    Join Date
    09-19-2017
    Location
    germany
    MS-Off Ver
    1707
    Posts
    7

    Re: I thought this would be easy

    As I am from germany the Formulas are in german, bit i hope you can see what i want to achieve.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: I thought this would be easy

    Clever old Bill Gates thought of that.... I see the formulae in English in your sheet. But I don't really understand what you are trying to do!!

  15. #15
    Registered User
    Join Date
    09-19-2017
    Location
    germany
    MS-Off Ver
    1707
    Posts
    7

    Re: I thought this would be easy

    The output of the second row is:
    We over a big variety of sunglasses and sunglasses in many different colors like yellow.

    I want it to be something like this:
    We over a big variety of shades and sunglasses in many different colors like yellow.

    I dont want it to use exactly the same word twice. But instead recalculate and choose a different (or only by chance the same) random item.

  16. #16
    Registered User
    Join Date
    09-19-2017
    Location
    germany
    MS-Off Ver
    1707
    Posts
    7

    Re: I thought this would be easy

    Maybe a solution would be if I could reference to the cell b4 but it would calculate the formula INDEX(B5:B100,ZUFALLSBEREICH(1,ZÄHLENWENN(B5:B100,"*"))) inside of the cell instead of just using the value "Sunglasses"

  17. #17
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: I thought this would be easy

    This is the way that I would do it....
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. This should be easy, but...
    By ernest t bass in forum Excel General
    Replies: 4
    Last Post: 05-08-2012, 10:10 PM
  2. Probably easy, but I don't get it
    By HaZeR86 in forum Excel General
    Replies: 1
    Last Post: 06-08-2009, 01:55 PM
  3. I bet this is easy,,,,,,
    By Roger_the_Dodger_55 in forum Excel General
    Replies: 5
    Last Post: 03-26-2009, 06:36 AM
  4. NEED HELP....easy
    By Chapman62083 in forum Excel General
    Replies: 3
    Last Post: 01-31-2009, 12:23 AM
  5. new user with easy question? not easy for me
    By speakeztruth in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 06-03-2005, 05:05 PM
  6. Easy for some, not for me
    By jtwhites85 in forum Excel General
    Replies: 1
    Last Post: 05-11-2005, 10:23 PM
  7. probably easy but...
    By jefftracy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-26-2005, 11:12 AM

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