Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default Key Generation

Start with:

Randomize Timer

rather than

Randomize Rnd()

which produces the same seed with every restart of Excel..

--
Jim
"Sri" wrote in message
...
Hi,

I am developing a "Project Tracker tool" using Excel VBA, where in people
will input their project details. Whenever a new project is submitted, I
have
to generate a unique Key for them (like a auto generated password), which
will be used in future to make any modifications, thereby securing it
safely.

So, I have tried using Randomise and Rnd to generate some random numbers
within a range and convert them in to some Alpha characters, which is
working
fine.
But the only issue is it keeps generating the same set of keys all the
time
and not unique sequences...

I'vel attached here the coding piece which i am using currently.....

""""
To produce random integers in a given range, use this formula:

Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

--------- This is taken from Excel help section....

""""

My code...........

Randomize Rnd()

s = Chr(Int((90 - 65 + 1) * Rnd + 65))
s = s & Chr(Int((122 - 97 + 1) * Rnd + 97))
s = s & Chr(Int((57 - 48 + 1) * Rnd + 48))
s = s & Chr(Int((57 - 48 + 1) * Rnd + 48))
s = s & Chr(Int((122 - 97 + 1) * Rnd + 97))
s = s & Chr(Int((90 - 65 + 1) * Rnd + 65))

The below ones are the numbers repeatedly generated for almost 50
projects,
sometimes in a chain, the same numbers repeats...

Dc31hK
Fc23rH
Gw18jP
Ow15xW

My queries a

1. Is the above piece of code correct? or can it be modified to generate a
unique sequence everytime.
2. Is there any other best way to do the same?

Thanks for your help.
--
Regards

Sri



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Generation rvExcelNewTip Excel Discussion (Misc queries) 9 May 17th 06 04:44 PM
Random Team Generation newbie Excel Discussion (Misc queries) 2 October 7th 05 05:14 PM
email generation Mir Khan Excel Discussion (Misc queries) 1 September 23rd 05 09:10 PM
Random Name Generation pkbro Excel Worksheet Functions 1 June 21st 05 02:03 AM
12 generation genelogy chart genelogy chart request Excel Discussion (Misc queries) 0 December 1st 04 09:37 PM


All times are GMT +1. The time now is 04:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"