Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Everyone,
I want to make a list,list items are numbers from 1 to 20. each tim i click commandbutton i want two random unique items from list to display textbox1 and textbox2. so for the next click those two items should remove from the list.Is that possible to do without function method? I just need one simple code in my userform. Thank you in advance Baha |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Store you numbers on a worksheet with this Private Sub UserForm_Initialize() With Sheets("Sheet1").Range("A1") .Value = 1 .DataSeries Rowcol:=xlColumns, Type:=xlLinear, _ Date:=xlDay, Step:=1, Stop:=20, Trend:=False End With End Sub The attach this code to your button Private Sub CommandButton1_Click() If WorksheetFunction.Count(Sheets("Sheet1").Range("A1 :A20")) < 2 Then MsgBox "Not enough values left" Exit Sub End If Do Mycell = Int((20 - 1 + 1) * Rnd + 1) FoundVal = Sheets("Sheet1").Range("A" & Mycell).Value Sheets("Sheet1").Range("A" & Mycell).Value = "" Loop Until FoundVal < "" TextBox1.Text = FoundVal Do Mycell = Int((20 - 1 + 1) * Rnd + 1) FoundVal = Sheets("Sheet1").Range("A" & Mycell).Value Sheets("Sheet1").Range("A" & Mycell).Value = "" Loop Until FoundVal < "" TextBox2.Text = FoundVal End Sub Mike " wrote: Hi Everyone, I want to make a list,list items are numbers from 1 to 20. each tim i click commandbutton i want two random unique items from list to display textbox1 and textbox2. so for the next click those two items should remove from the list.Is that possible to do without function method? I just need one simple code in my userform. Thank you in advance Baha . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Mike,
I absulatelly whant I want. Thank you very much for the help. Baha |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unique random numbers from list | Excel Discussion (Misc queries) | |||
Applying random changes to a list of numbers | Excel Discussion (Misc queries) | |||
Random list (1-45) without repeating numbers? | Excel Worksheet Functions | |||
Random Numbers from list | Excel Programming |