Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions