LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Random Text in a userform textbox

If you only want the text from one cell on a random selection then
To randomize you could do:

Dim rng as Range, i as Long, j as Long
Dim cell as Range
Set rng = Range("A1:B1,B3,C5,B8,C10")
i = int(rnd()*rng.count+1)
j = 0
For Each cell In rng
j = j +1
if j = i then
TextBox1.Text = cell.Value
exit for
End if
Next

--
Regards,
Tom Ogilvy

"Toppers" wrote in message
...
Hi,
Something like this? Put in "Userform_Initialize" routine

Set rng = Range("A1:B1,B3,C5,B8,C10")
mystr = ""
For Each cell In rng
mystr = mystr + cell.Value & " "
Next
textbox1.Text = mystr

"Soniya" wrote:

Hi All,

Is it possible to display random text from a range of cells in a
userform textbox when the userform is activated?

Also if the range refers to non contiguous cells.

Thanks




 
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
highlight text in userform textbox RB Smissaert Excel Programming 1 November 2nd 05 11:44 PM
Using The Text From A Textbox In A UserForm Donna[_7_] Excel Programming 2 February 24th 05 03:25 PM
Qn: Display Text in TextBox in Userform Michael Vaughan Excel Programming 1 August 18th 04 05:06 PM
formatting text in TextBox in UserForm Kevin Excel Programming 2 November 7th 03 01:34 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 09:13 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"