I have 32 names in 32 cells. Against each one is a number.
I want to create a button (done that bit), and when you click it, it randomly sorts the names against the numbers.
How do I do that in Excel VBA ?
Printable View
I have 32 names in 32 cells. Against each one is a number.
I want to create a button (done that bit), and when you click it, it randomly sorts the names against the numbers.
How do I do that in Excel VBA ?
Add an extra (hidden) column that has a =Rand() function beside each name. The when you need to sort just use the random values as your sort key.
Good idea. Done that ... but for some weird reason the 1st entry always stays as the same value, even though its associated randomly generated number changes each time ?!?!?!
Use the Randomize method before any calls the the Rnd function.
That may be because Excel is treating the first row as a header row. Within your call to the sort method, setting the value of the Header attribute to xlNo should correct this.
Doh !
That did it.
Cheers guys :)
(Thats the World Cup team sweepstake random generator program taken care of !)
Important work indeed!
always ;)
Gambling at work? Tsk tsk. :D
moi ? never :evil grin:
Wahich was it that fixed the issue?
Making the header "No" instead of "Guess".
Should have spotted it !
Oops ... need to "resolve" the thread ....