Conditions and Loops
Exercise 3.02

Exercise 3.02

The aim of this exercise is to loop over a list of films and use conditional functions to calculate values for each row.

Files Needed

Click here to download the file needed for this exercise.

Instructions

  1. Extract and open the Movies.xlsm workbook to find a worksheet containing a list of films:
Top of list

The first three films in the list are shown here.

  1. Create a subroutine which begins by selecting cell A2.
  2. Add a conditional loop to the subroutine which selects the cell below the active cell and continues doing so until a blank cell is selected.
  3. Within the loop, use an IIf function to assign a value to the Success column (column D) based on the number of Oscars a film has won:
Oscars Success
0 Loser
1 or more Winner
  1. Within the loop, use a Switch function to assign a value to the Length column (column F) based on the Run Time of a film:
Run Time Length
< 100 Short
100 - 149 Medium
150 - 199 Long
>= 200 Epic
  1. Run the subroutine you have written and check that you see the expected results:
Results

A selection of results from the list.

  1. Save and close the workbook.

Answer Files

Click here to download a file containing a suggested answer.

This page has 0 threads Add post