Randomize from set of values
Hi,
Try this
Sub marine()
Dim AaRRay As Variant
Dim NaRRay As Variant
Dim r As Long, x As Long
r = 1
AaRRay = Array("C", "F", "G", "H", "J", "K", "M", "N", "P", "Q", "R", "S",
"T", "W", "X", "Y", "Z")
NaRRay = Array("2", "4", "5", "6", "7", "9")
Debug.Print AaRRay(3)
For nums = 1 To 72
Do
For x = 1 To 3
pos = Int((13 - 0 + 1) * Rnd + 0)
mystring = mystring + AaRRay(pos)
Next
For x = 1 To 3
pos = Int((5 - 0 + 1) * Rnd + 0)
mystring = mystring + NaRRay(pos)
Next
Cells(r, 1).Value = mystring
Loop Until WorksheetFunction.CountIf(Range("A1:A" & r), Range("A" & r)) = 1
r = r + 1
mystring = ""
Next
End Sub
mike
"Bam" wrote:
Hi All,
I was given a task of making a unique set of random (72 x 6 digit)
alphanumeric from the following available letters & numbers.
C F G H J K M N P Q R S T W X Y Z
2 4 5 6 7 9
The format is to be like this CFG245.
All 72 Values must be unique.
They must all be 3 alpha & 3 numeric, in that order.
I had a look at zrandom, but couldn't see it doing this task for me.
Has anyone the ability to code something like this in vba?
Or is this simply beyond excel's capabilities??
Any assistance would be much appreciated.
Cheers,
Bam.
|