L

#### L. Howard

Place 20 numbers in six columns at random with no dupes where:

Col C 1 to 20

Col E 21 to 40

Col G 41 to 60

Col I 61 to 80

Col K 81 to 100

Col M 101 to 120

Column C numbers are fine, 1 to 20 randomly from C2 to C21.

All the other column do the same except the code puts a 0 (zero) where the max number for that column should be.

So for column K for example, I get 81 to 99 and a 0 (zero) all and randomly placed each time I run the code.

The Msgbox shows the correct Small and Big numbers as the code loops, exactly like the pattern above for each loop.

At a loss.

Thanks,

Howard

Option Explicit

Sub Columns_CEGIKM() 'Rothstein, Jim

Application.ScreenUpdating = False

Dim X As Long, Small As Long, Big As Long, Index As Long, Temp As Long, Numbers() As Long

Dim NumberOfRandoms As Long

Dim i As Long

Dim MyCol As Long

Small = 1

Big = 20

MyCol = 3

On Error Resume Next

For i = 1 To 6

MsgBox Small & " " & Big

NumberOfRandoms = Big

' Load up an array with all the values for the range of random numbers

ReDim Numbers(1 To Big - Small + 1)

For X = Small To Big

Index = Index + 1

Numbers(Index) = X

Next

' Randomly mix up the values in the array

For X = UBound(Numbers) To LBound(Numbers) Step -1

Index = Int((X - LBound(Numbers) + 1) * Rnd + LBound(Numbers))

Temp = Numbers(Index)

Numbers(Index) = Numbers(X)

Numbers(X) = Temp

Next

' Output the number of randoms specified by the NumberOfRandoms constant to the worksheet

For X = 1 To NumberOfRandoms

'/ starts list in C2 and down

Cells(X + 1, MyCol).Value = Numbers(X)

Next

MyCol = MyCol + 2

Small = Small + 20

Big = Big + 20

Next 'i

Application.ScreenUpdating = True

End Sub