Random numbers, Canadian Zip Code style

  • Thread starter Thread starter Shocked
  • Start date Start date
S

Shocked

In a previous job, we used Lotus Notes. To generate unique identifier
for individual forms and other documents (complaints, datasheets, etc.
a number/letter combination was generated based on the time and in th
style of Canadian Zip Codes.

Does anyone have any idea how this could be done in Excel
 
Certainly you can do it, but you need to decide on the algorithm to be used:
what sort of arithmetic do you want to do on the time to translate it?
 
In a previous job, we used Lotus Notes. To generate unique identifiers
for individual forms and other documents (complaints, datasheets, etc.)
a number/letter combination was generated based on the time and in the
style of Canadian Zip Codes.

Does anyone have any idea how this could be done in Excel?

Yes. here is one way to do it.

First, create a column containing all the letters in the alphabet,
A-Z. Name the first cell in this column A.

Then, create another column containing the numbers 0-9.
Name the first cell N.

Thwe following formula will generate a Canadian style Postal Code each
time the worksheet recalculates (use F9 to force recalc).

=OFFSET(A,RANDBETWEEN(1,26)-1,0,1,1)&OFFSET(N,RANDBETWEEN(0,9),0,1,1)&OFFSET(A,RANDBETWEEN(1,26)-1,0,1,1)&"
"&OFFSET(N,RANDBETWEEN(0,9),0,1,1)&OFFSET(A,RANDBETWEEN(1,26)-1,0,1,1)&OFFSET(N,RANDBETWEEN(0,9),0,1,1)

You could put the letters and numbers in two rows, but then you would
have to change the row/column parameters in the OFFSET calls.

In theory, the codes generated this way are not unique, but the chance
of duplicating one is of the order of one in 1000*26^3 (approx. 17.5
million).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top