ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Random select of text (https://www.excelbanter.com/excel-worksheet-functions/179234-random-select-text.html)

Tanya

Random select of text
 
Hi,
I have a list of questions, which I want to be selected on another sheet at
random, the range is Sheet1!A1:A10 and when I run a command, I wish to have
one of the questions from the selected range chosen at random.
ie. [very simplistic example]
Sheet 1
A1 = What colour is grass?
A2 = What colour is the sky?

Sheet 2
A1 contains the result of this function and is calculated when the function
is called by a command button.

I hope this all makes sense?

Thanking you all in advance.

Cheers
Tanya

JMB

Random select of text
 
you could paste this macro into a vba module and assign it to a forms button
on the worksheet

Sub Test()
Dim lngRandom As Long

Randomize
lngRandom = Int((10 * Rnd) + 1)
Range("A1").Value = Worksheets("Sheet1").Range("A" & lngRandom)

End Sub



"Tanya" wrote:

Hi,
I have a list of questions, which I want to be selected on another sheet at
random, the range is Sheet1!A1:A10 and when I run a command, I wish to have
one of the questions from the selected range chosen at random.
ie. [very simplistic example]
Sheet 1
A1 = What colour is grass?
A2 = What colour is the sky?

Sheet 2
A1 contains the result of this function and is calculated when the function
is called by a command button.

I hope this all makes sense?

Thanking you all in advance.

Cheers
Tanya


Tanya

Random select of text
 
Thank you JMB,
works great!

cheers
Tanya

"JMB" wrote:

you could paste this macro into a vba module and assign it to a forms button
on the worksheet

Sub Test()
Dim lngRandom As Long

Randomize
lngRandom = Int((10 * Rnd) + 1)
Range("A1").Value = Worksheets("Sheet1").Range("A" & lngRandom)

End Sub



"Tanya" wrote:

Hi,
I have a list of questions, which I want to be selected on another sheet at
random, the range is Sheet1!A1:A10 and when I run a command, I wish to have
one of the questions from the selected range chosen at random.
ie. [very simplistic example]
Sheet 1
A1 = What colour is grass?
A2 = What colour is the sky?

Sheet 2
A1 contains the result of this function and is calculated when the function
is called by a command button.

I hope this all makes sense?

Thanking you all in advance.

Cheers
Tanya


JMB

Random select of text
 
glad to hear it worked for you - thanks for the feedback

"Tanya" wrote:

Thank you JMB,
works great!

cheers
Tanya

"JMB" wrote:

you could paste this macro into a vba module and assign it to a forms button
on the worksheet

Sub Test()
Dim lngRandom As Long

Randomize
lngRandom = Int((10 * Rnd) + 1)
Range("A1").Value = Worksheets("Sheet1").Range("A" & lngRandom)

End Sub



"Tanya" wrote:

Hi,
I have a list of questions, which I want to be selected on another sheet at
random, the range is Sheet1!A1:A10 and when I run a command, I wish to have
one of the questions from the selected range chosen at random.
ie. [very simplistic example]
Sheet 1
A1 = What colour is grass?
A2 = What colour is the sky?

Sheet 2
A1 contains the result of this function and is calculated when the function
is called by a command button.

I hope this all makes sense?

Thanking you all in advance.

Cheers
Tanya



All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com