Sign in to follow this  

How to create random name using excel, VB or Access?

This topic is 3664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i need some help over here. i wan to make a generator which can help me random pick a name. it is able to remove the name after it been used. i trying to make it for lucky draw.

Share this post


Link to post
Share on other sites
Why don't you just hard code a list of first (and/and-not last) names...keep a flag next to each saying if its been used or not, and pick randomly until you find an unflagged name? There is no upper bound on the running time but statistically should be completely negligible for this purpose, but if you wanted to be a stickler about it you could move each picked name to the back of the list and modulo your random number by the active size of the remaining names as you whittle it down..

Share this post


Link to post
Share on other sites
Since you just want to pick a random name,

Enter them all into a column in Excel, go into the VB editor and create a Subroutine.

In the subroutine you just need to get the number of columns in the listobject, get a random number in this range and use that to get your name (since you know the column and that will give you the row). Once you have the name, just swap that row with the last row and delete the last row. Easy stuff.

I'd give you code, but I'm pretty terrible at VB (since I use it about one day a year), and you can probably find a carbon copy program in ten seconds on Google.

Share this post


Link to post
Share on other sites
how to generate the name? do i use textbox to show the random name show up?

what will the scripting like if i wan to click on the run button to let the random run and pick a name for the winner?

i try putting random something but error.

Share this post


Link to post
Share on other sites

This topic is 3664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this