Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
highlight text in userform textbox | Excel Programming | |||
Using The Text From A Textbox In A UserForm | Excel Programming | |||
Qn: Display Text in TextBox in Userform | Excel Programming | |||
formatting text in TextBox in UserForm | Excel Programming | |||
UserForm TextBox to ActiveSheet TextBox over 256 characters | Excel Programming |