Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Msgbox with randomly picked text
Hello everybody,
I would like to create a message box with random message picked from a list preset in the cells of the workbook itself. May be the example below will be more clear: On sheet2: Cell A1= blablabla cell A2= totototo cell A3= yepyepyep Then the message box would give either the text in A1 or A2 or A3. As my knowledge in VBA is quite limited it would be very nice if one of you could give me a hand. Thank you. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Msgbox with randomly picked text
sub ABC()
set rng = Range("A1:A3") i = int(rnd()*rng.count + 1) msgbox rng(i) End Sub -- Regards, Tom Ogilvy "Cajeto 63" wrote: Hello everybody, I would like to create a message box with random message picked from a list preset in the cells of the workbook itself. May be the example below will be more clear: On sheet2: Cell A1= blablabla cell A2= totototo cell A3= yepyepyep Then the message box would give either the text in A1 or A2 or A3. As my knowledge in VBA is quite limited it would be very nice if one of you could give me a hand. Thank you. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Msgbox with randomly picked text
Wonderful Tom,
It's simple, I can understand it, and it works. Thank you very much for you help. "Tom Ogilvy" wrote: sub ABC() set rng = Range("A1:A3") i = int(rnd()*rng.count + 1) msgbox rng(i) End Sub -- Regards, Tom Ogilvy "Cajeto 63" wrote: Hello everybody, I would like to create a message box with random message picked from a list preset in the cells of the workbook itself. May be the example below will be more clear: On sheet2: Cell A1= blablabla cell A2= totototo cell A3= yepyepyep Then the message box would give either the text in A1 or A2 or A3. As my knowledge in VBA is quite limited it would be very nice if one of you could give me a hand. Thank you. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Msgbox with randomly picked text
Hi,
Sub test() Dim nt As Integer Randomize 'to initialize the random-number generator 'Int((upperbound - lowerbound + 1) * Rnd + lowerbound) 'from help nt = Int((3 - 1 + 1) * Rnd + 1) MsgBox worksheets(2).Range("A" & nt) End Sub Regards Jean-Yves "Cajeto 63" wrote in message ... Hello everybody, I would like to create a message box with random message picked from a list preset in the cells of the workbook itself. May be the example below will be more clear: On sheet2: Cell A1= blablabla cell A2= totototo cell A3= yepyepyep Then the message box would give either the text in A1 or A2 or A3. As my knowledge in VBA is quite limited it would be very nice if one of you could give me a hand. Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Identifying the presence of a randomly ordered text string in a cell | Excel Worksheet Functions | |||
what can I do to randomly select cells that contain text? | Excel Worksheet Functions | |||
Column picked randomly with probability relative to number of entr | Excel Worksheet Functions | |||
If certain item is picked, then text added... | Excel Discussion (Misc queries) | |||
i have fields that are formatted for text that randomly convert t. | Excel Discussion (Misc queries) |