p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Excel VBA (http://p2p.wrox.com/forumdisplay.php?f=79)
-   -   Product code generator (http://p2p.wrox.com/showthread.php?t=62566)

yogeshyl October 3rd, 2007 10:07 AM

Product code generator
Need some formula to generate a 13 digit code for the products.


allenm October 3rd, 2007 10:50 AM

Should the code contain just numbers? Just Letters? A mixture? Are the first few letters and the last few numbers? Is the code completely random? Are duplicate codes acceptable?

There isn't very much information to go on to generate a solution for.

If you just want a random set of numbers extended to 13 digits, then this would work:
Dim iCnt As Integer, sCode As String
For iCnt = 1 to 13
  sCode = sCode & Int((Rnd * 10)) 'Concatenates random number between 0 and 9
MsgBox "The generated code is: " & sCode

The above doesn't check to see if there was a duplicate. You'd have to check the result against a list for that.
If you are looking for anything more specific then more information on what is desired is needed.

All times are GMT -4. The time now is 05:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.