560 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
Open the file called Lucky Dip.xlsx and create a subroutine to generate a set of random lottery numbers:
You need to create 6 random numbers between 1 and 59 (they don't need to be in order).
To do this, start by looping over the six cells that you need to populate using a For Each loop. Inside the loop, add a line which generates a random number between 1 and 59 and captures it in a variable. You can use the RandBetween function to do this:
Num = WorksheetFunction.RandBetween(1, 59)
Add a line to write the number in the variable into the cell that the loop is pointing to, then run the subroutine a few times to test it.
One problem is that you might generate the same number multiple times.
Add a Do Loop structure around the line which calculates a random number. Add a condition to this loop so that it continues Until it generates a number that isn't already in the worksheet.
You could use the Find method and check that its result Is Nothing to establish that the number isn't already in the worksheet.
Add a line at the start of the subroutine which clears the contents of the cells you're looping over.
If you'd like to see your numbers sorted, you could add the code shown below:
.Orientation = xlLeftToRight
Save and close the workbook.
25 Aytoun Street