Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Display text at random

Hi all...

Can anyone please post a detailed way of how I can display text lines at
random
in a specific cell when I press a macro button.
The text is pre-typed in the module I would assume. Also how can I set all
this up to work together?
It would a great help if anyone can assist.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 62
Default Display text at random

I can actually field this, so here's my take:

Create an array with all your values. Then create a random number,
and that number refers to one of the entries in your array.
If you input the code below into a module, it should work and you can
tweak it as you need be.

Since, NP

------------------------------

Sub RandomLines()

Dim RandomLinesArray(0 To 4) As Variant
Dim RandomNumber As Long

RandomLinesArray(0) = "ZERO"
RandomLinesArray(1) = "ONE"
RandomLinesArray(2) = "TWO"
RandomLinesArray(3) = "THREE"
RandomLinesArray(4) = "FOUR"

RandomNumber = Int((5 - 1 + 1) * Rnd + 1) - 1

Sheets("Sheet1").Range("A1").Value = RandomNumber
Sheets("Sheet1").Range("A2").Value = RandomLinesArray(RandomNumber)

End Sub

On 725, ȫ3:39, Markv wrote:
Hi all...

Can anyone please post a detailed way of how I can display text lines at
random
in a specific cell when I press a macro button.
The text is pre-typed in the module I would assume. Also how can I set all
this up to work together?
It would a great help if anyone can assist.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Display text at random

thanks a lot for your patient reply..I will give it a go.


"pallaver" wrote:

I can actually field this, so here's my take:

Create an array with all your values. Then create a random number,
and that number refers to one of the entries in your array.
If you input the code below into a module, it should work and you can
tweak it as you need be.

Since, NP

------------------------------

Sub RandomLines()

Dim RandomLinesArray(0 To 4) As Variant
Dim RandomNumber As Long

RandomLinesArray(0) = "ZERO"
RandomLinesArray(1) = "ONE"
RandomLinesArray(2) = "TWO"
RandomLinesArray(3) = "THREE"
RandomLinesArray(4) = "FOUR"

RandomNumber = Int((5 - 1 + 1) * Rnd + 1) - 1

Sheets("Sheet1").Range("A1").Value = RandomNumber
Sheets("Sheet1").Range("A2").Value = RandomLinesArray(RandomNumber)

End Sub

On 7月25日, 午後3:39, Markv wrote:
Hi all...

Can anyone please post a detailed way of how I can display text lines at
random
in a specific cell when I press a macro button.
The text is pre-typed in the module I would assume. Also how can I set all
this up to work together?
It would a great help if anyone can assist.

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random select of text Tanya Excel Worksheet Functions 3 March 8th 08 02:50 PM
Random Text selection Q Sean Excel Worksheet Functions 4 February 20th 08 11:05 PM
Random sort function for text Devin Excel Worksheet Functions 1 October 18th 07 10:44 PM
Random selection of text cells CJ Excel Discussion (Misc queries) 3 September 10th 06 07:05 AM
random number with text T Harris Excel Worksheet Functions 10 December 30th 05 04:34 PM


All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"