+ Reply to Thread
Results 1 to 5 of 5

Getting the text from a random cell / row

  1. #1
    Registered User
    Join Date
    10-06-2007
    Posts
    2

    Getting the text from a random cell / row

    Hello!

    I've made myself an archive listing all of my cd's. One column for artist, one for album, one for production-year, etc..

    I want excel to pick a random artist and album-name, and display it. How can I do this? It shouldn't be impossible I'm using regular excel 2003, with no extras.

    I started off with =INT(rand()*(720-9)+9) (I've tried to translate it to english) This picks a random row-number for me. But what next? And I was thinking maybe I could define a variable x=("randomnumber"), and write something like =INDIRECT("Ax"), but as you probably know, it doesn't work that way I can't find a way to display the text from a cell with this number!

    I'm to be considered as an excel-amateur, so you should probably keep that in mind

    (I hope I'm posting in the right place, I wasn't quite sure)

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064
    Assuming col A = artist, col B = album
    In say D1

    =INT(RAND()*<number of CDs)+1

    In E1

    =INDIRECT("A"&D1) will give you artist

    In F1

    =INDIRECT("B"&D1) will give you that artist's album
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    If your artists are in A and your Album name is in column B

    Then try

    For Artists:

    =INDIRECT("A"&INT(rand()*(720-9)+9)) or =INDEX(A:A,INT(rand()*(720-9)+9))

    For Album:

    =INDIRECT("B"&INT(rand()*(720-9)+9)) or =INDEX(B:B,INT(rand()*(720-9)+9))

    You can replace your INT function with a cell reference containing the formula if you wish.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    10-06-2007
    Posts
    2
    Thanks guys!

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    If you use INDEX then INT can be discarded because INDEX will truncate the index number anyway.

    If you have alist of CDs starting at A9 this will allow you to select one at random and also add CDs to the list (up to row 1000) without altering the formula

    =INDEX(A9:A1000,COUNTA(A9:A1000)*RAND()+1)

+ 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