Question: Option Explicit Sub lottry() ' declearing variables Dim lootry(), user() As Double Dim count, i, x, j, score As Integer ' selecting sheet Sheet1.Activate '

Option Explicit

Sub lottry()

' declearing variables

Dim lootry(), user() As Double

Dim count, i, x, j, score As Integer

' selecting sheet

Sheet1.Activate

' pools size input from sheet

x = Cells(8, 7)

' counting the number of cells that the user used

count = Range("b3", Range("b4").End(xlDown)).Cells.count - 1

' redeclearing user arry .

ReDim user(1 To count)

' looping over user arry to populate it

For j = 1 To count

user(j) = Cells(j + 3, 2)

Next j

' rediming arrys after founding the count

ReDim lootry(1 To count)

' looping over lootry arry to populate it

For i = 1 To count

lootry(i) = Int(Rnd * x)

Cells(i + 3, 5) = lootry(i)

Next i

' loopint to compare betweer values stored in user arry to values stored in lootry arrys

' the score increas with each matching values .

For j = 1 To count

For i = 1 To count

If user(j) = lootry(i) Then

score = score + 1

Cells(5, 7) = score

End If

Next i

Next j

End Sub

The program which is in ( VBA ) is working , the only problem is that its generating duplicate random numbers .

Could you modify the program so it generate random numbers without repeating the number .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!