Reference no: EM132375453
Assignment -
This assignment needs to be completed in VBA within the macro spreadsheet.
Objective:
- Use a For Each loop to create a list of schools and display in a message box.
- Use nested For Loops to create a list of all possible pairs of comparisons for a given number of options.
Instructions: This will be all new code.
Part A: School List
Create a range variable (named rngIndex) that represents the list of numbers in column A of the Data sheet.
SET that variable to cells A2 to A21 of the Data sheet but DO NOT hardcode the reference.
Use a combination of Offset and End(xlDown) to determine the current size of the range.
Loop through each cell in rngIndex and create a string variable (strList) that shows the AlphaOrder, Name and Mascot where mascot is in uppercase. (Use UCASE function.)
Display that string in a message box as in the example.
Attach the code to this button to execute.
Lines of code needed: about 10.
Part B: Nested Loops to create pair sets to compare
When comparing every option to every other option, we can determine the number of options with the formula - pairs = (options - 1) * (options) / 2
Prompt the user to enter the number of options, then display in a messagebox the number of pairs to be created.
Pass that value to a new sub that handles the next steps.
Use a pair of nested loops to create every possible pair without repeating any pairs. Print each pair to the immediate window using Debug.Print. (assuming user entered 6 as in the example screen shots, output would resemble)
Attach code to the Make Pairs button.
Attachment:- Assignment File.rar