+ Reply to Thread
Results 1 to 8 of 8

Dynamically displaying cells based on a random number

  1. #1
    Registered User
    Join Date
    01-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Dynamically displaying cells based on a random number

    I've been fiddling around with a certain document in Excel and I want to add a feature which I just can't seem to wrap my head around.

    My doc randomly generates an integer in Cell A1 using
    Please Login or Register  to view this content.
    I have a list of text values in 100 cells [A2-A101] after that, and in a new cell B1 I want to display the content of whichever cell from the list of 100 corresponds to the randomly generated number in A1.

    Is this possible? Is it, in fact, easy as pie?
    Last edited by royUK; 01-24-2012 at 02:12 PM.

  2. #2
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Dynamically displaying cells based on a random number

    When you say text values you mean numbers from 1 to 100 yes? What your asking for is just returning the same number that is in A1 correct?

    =VLOOKUP(A1;A2:A100;1;0)

    If you just want to duplicate the number you could make B1=A1.

    If I'm missing something could you post the spreadsheet? Did you want to know the cell reference instead?

  3. #3
    Registered User
    Join Date
    11-06-2011
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Dynamically displaying cells based on a random number

    Does this work:

    =INDEX(A2:A100,A1)

  4. #4
    Registered User
    Join Date
    01-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Dynamically displaying cells based on a random number

    Quote Originally Posted by darknation144 View Post
    When you say text values you mean numbers from 1 to 100 yes?
    Not quite. They're words. String values, I think they're often called?

    Anyway, here's the sheet - I was using A1, A2 etc for simplicity's sake, the actual values are:
    B7 - the random number generator
    B22-B121 - The list of words
    D7 - the place where I'd like the result

    npc-personality-traits.xls

  5. #5
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Dynamically displaying cells based on a random number

    You need to use Index and Match.

  6. #6
    Registered User
    Join Date
    11-06-2011
    Location
    Massachusetts, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Dynamically displaying cells based on a random number

    The INDEX solution I put forward earlier works with words.

  7. #7
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Dynamically displaying cells based on a random number

    npc-personality-traits.xls

    Hope this works I wrote this on calc but hopefully I changed all the ; to ,

    Didn't seem to work basically here is the code
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-24-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Dynamically displaying cells based on a random number

    Quote Originally Posted by darknation144 View Post
    Attachment 137926

    Hope this works I wrote this on calc but hopefully I changed all the ; to ,

    Didn't seem to work basically here is the code
    Please Login or Register  to view this content.

    This worked excellently! Thanks so much for all of your help, everyone!

+ 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