Spreadsheet forumula questions to pick a random DVD

I have a list of my (279) DVD’s in an OpenOffice Spreadsheet (version 3.3.0) on my Windows 7 laptop and I want to create a formula to randomly pick a film to watch (for occasions when I can’t make up my mind). This works:

=RANDBETWEEN(1;279)

But all it gives is a number that I have to then scroll up and down to check and it also has the total number of DVD’s ‘hard coded’. I want to display the name of the film (held in column A) so that if, for example, the number was 277, the name of the film would appear, in this case ‘X-Men 2’. I assumed that just adding the column letter in the front like this:

=A(RANDBETWEEN(1;279))

would work but it throws up an error: #NAME?

So, how can I...

  1. Make it display the name of the film
  2. Automatically detect the top number as I add new DVD’s so I don’t have to hard code it into the formula?
  3. How can I make it so that I just click the cell to regenerate a new random number? (i.e. not have to recalculate manually by pressing Shift+Ctrl+F9)

Thanks.


  1. To return the value from column A, row R, you can use =INDIRECT("A"&R)

  2. To count the number of values in column A, you can use =COUNTA(A1:A65536)

    So for your case, you could use =INDIRECT("A"&RANDBETWEEN(1;COUNTA(A1:A65536)))

  3. You might be able to make a macro button that will recalculate for you. I don't know enough about OpenOffice.org Calc's macro language to provide more help there.