PDA

View Full Version : Solved: Could you please help me to use VBA for random name



42320135
11-20-2011, 07:29 PM
Dear Guru
I have a project
In December our company will to have New year party.
I have requirement from staff.
need to make program random employee ID number for receive prize
But I don't know how to, If possible if someone have a code use by VBA could you please advice me.
Becuase I don't have any expernince for EXCEL VBA
< Concept >
1. Make Sheet1 to keep ID number and Name.
2. Sheet2 to make button on click to random ID Number from sheet1
3. Random Timing 10 second
4. When random fininsh show ID number and Name in sheet2
(if ID number already receive prize 1 time status show " You already receive or ID Number is duplicate ")

Could you please help
Becuase I don't have any experince for make it.

Thank you for all help me
Regards

mikerickson
11-20-2011, 09:23 PM
Make a list of employees.
Put =RAND() in the cells next to their names.
Sort that 2 column range on the Rand column.
The name at the top is the first one "drawn from the hat"
The next name down is second, etc.

42320135
11-20-2011, 11:22 PM
Make a list of employees.
Put =RAND() in the cells next to their names.
Sort that 2 column range on the Rand column.
The name at the top is the first one "drawn from the hat"
The next name down is second, etc.

Thank you very much for advice me.
I am new member to use VBA and don't have any experience to make it.
if possible could you please past the code for me.
Sorry for inconvenience
Please help me.

mikerickson
11-21-2011, 12:06 AM
That isn't VBA, its native Excel.

42320135
11-21-2011, 06:43 PM
That isn't VBA, its native Excel.

Now I already made Excel file.
When need to random need to push F9, this Excel can random it

If need to input Button to click for random. (Not push F9)
How to make code in this button.
Could please advice me

Simon Lloyd
11-21-2011, 07:06 PM
Create your RAND as pointed out earlier on a worksheet then add a button from the forms toolbox, create a macro like thisSub Calc_Rand()
Application.CalculateFull
End Suband assign that macro to the button, its just like pressing F9 :)

42320135
11-22-2011, 07:51 PM
Create your RAND as pointed out earlier on a worksheet then add a button from the forms toolbox, create a macro like thisSub Calc_Rand()
Application.CalculateFull
End Suband assign that macro to the button, its just like pressing F9 :)

Wow thank you very very much sir.
And also I have another question :

When click button Random , I need to running time for Random 10 Sec
How to make code.

Could you please help me

Bob Phillips
11-22-2011, 08:26 PM
Try this

42320135
11-22-2011, 09:10 PM
Try this

Thank you very much sir....
it greats excel sir,

Regards