Random select of text

T

Tanya

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
 
J

JMB

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
 
T

Tanya

Thank you JMB,
works great!

cheers
Tanya

JMB said:
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 said:
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
 
J

JMB

glad to hear it worked for you - thanks for the feedback

Tanya said:
Thank you JMB,
works great!

cheers
Tanya

JMB said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top