I have a list of 500 names in CSV, i want to have a visual basic graphic code or a macro that can help me select 5 winners of these
I have a list of 500 names in CSV, i want to have a visual basic graphic code or a macro that can help me select 5 winners of these
Hi arn2025,
Enter the below formula in the next column and drag it down 5 cells..
=OFFSET($A$1,RANDBETWEEN(0,499),0)
Regards,
DILIPandey
<click on below 'star' if this helps>
DILIPandey, Excel rMVP
+919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com
You can make a simple random number generator as a function that you can reuse as needed. Then you can make a loop that uses the number generator as many times as you like. If you're only getting 5 out of 500, you shouldn't have too much trouble with getting a unique number with a brute force method. Then you use the random number as an index for your names.
This is a pretty typical RNG function:
lowerbound is the lowest possible number and upperbound is the highest, so you would call RandNum(1,500) to get a number between 1 and 500. Here's a macro that returns five unique numbers, using the above function:![]()
Please Login or Register to view this content.
I'm sure there is a more elegant approach, but that will get the job done. Then you just use an offset for the names according the randomly selected indices.![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks