IE 212: Computational Methods for Industrial Engineering Summer 2015 Homework #5: Writing sub procedures Thursday, July 23rd, 2015 IMPORTANT NOTES To obtain full credit in this homework, you must: Submit a single Excel file via The Engineering Accounts & Classes (T.E.A.C.H.) homepage (http://engr.oregonstate.edu/teach) before the beginning of the lecture session on Thursday, July 23rd, 2015 at 1:00 PM. Late submission is not allowed. - Before submitting your solution file via T.E.A.C.H., make sure that the sample data provided for each problem is in the format it was before you tested your sub procedures. This will simplify the grading process. Submit a hard copy of the last page included in this document at the beginning of the lecture session on Thursday, July 23rd. - Do not forget to add your name electronically to this page. Solutions for each individual problem should be prepared in separate worksheets. Make sure to follow good programming practices. In particular: Add comments to document your code, and Use indentation to make your code more readable and easier to grade. PROBLEMS Open a blank Excel workbook and save it as a MACRO-ENABLED file using the naming convention “YourLastName_Hmw5.xlsm.” Your workbook must contain only two worksheets named "Prob1" and "Prob2", respectively. In the Visual Basic Editor (VBE), insert a new module into the Project Explorer and write (do NOT record) all your sub procedures inside this module. Problem 1 (20 pts) 1. Write a sub procedure named Count_Down that displays a countdown from “3” to “1” using worksheet cells to represent the numbers. The numbers should be displayed as depicted in Figure 1. a) Use the Cells property of the Range object to create the numbers in the countdown. You may use any cell in the worksheet "Prob1" as the base cell (i.e., 1th row and 1th column cell) when using the Cells property. As an added challenge, create the numbers for the countdown with the fewest possible number of Cells statements. For example, the number “3” can be created with only three Cells statements. b) Assign the sub procedure Count_Down to a rectangular shape button. The caption of the rectangular shape button should read “START”. The rectangular shape button should be visually appealing and its upper left corner should be aligned with the upper left corner of cell B2. c) After the “START” button is pressed, the display of the first number (i.e., “3”) should be delayed two seconds. After that, every number in the countdown should stay visible for exactly one second and then disappear. You must also use the Cells property to make the numbers in the countdown disappear. As an added challenge, make the numbers disappear with the fewest possible number of Cells statements. For example, a single Cells statement is needed to make the number “3” disappear. d) The legend “GO!” should be displayed in cell E5 immediately after the number “1” disappears. Use capital letters and BOLD font style for this legend, center the legend in cell E5, and set the interior color of cell E5 to GREEN. e) Your sub procedure should end by selecting cell A1. Figure 1. Example screenshots for problem 1. 2. Write a sub procedure named Reset that will: a) Replace the legend “GO!” with the legend “READY?” in cell E5. Use capital letters and BOLD font style for this legend, center the legend in cell E5, and set the interior color of cell E5 to RED. b) Assign the sub procedure Reset to a rectangular shape button. The caption of the rectangular shape button should read “Reset”. The rectangular shape button should be visually appealing and its upper left corner should be aligned with the upper left corner of cell B7. Problem 2 (30 pts) Manually create a data table exactly as shown in Table 2 into worksheet "Prob2". Manually set all the cells in the data table to be left aligned. Table 2. Data for Problem 2. SOLUTION REQUIREMENTS: 1. Write a sub procedure named Format_Table that will: a) Use the Name property of the Range object to name the data table (i.e., range B3:J10) as “Western_Conference”. Using the named range, do the following: Use any color (except Black and White) to highlight the statistics for the “Portland Trailblazers” using the Rows property. Use any color (except Black and White) to highlight the information in the column labeled “Percentage” of the named range using the Columns property. Change the alignment of the columns labeled “Won” and “Streak” in the named range to centered using the EntireColumn property. (Hint: Investigate if the EntireColumn property can be indexed.) b) Use conditional formatting to identify those cells in the column labeled “Lost” that contain a value greater than 15. Cells that meet this criterion must have their fill color changed to RED and the font type to BOLD. c) Assign the sub procedure Format_Table to a rectangular shape button. The caption of the rectangular shape button should read “Format Table”. The rectangular shape button should be visually appealing and its upper left corner should be aligned with the upper left corner of cell D13. d) Your sub procedure should end by selecting cell A1. 2. Write a sub procedure named Restore_Table that will: a) Undo all the changes applied to the original table by sub procedure Format_Table. b) Assign the sub procedure Restore_Table to a rectangular shape button. The caption of the rectangular shape button should read “Undo Changes”. The rectangular shape button should be visually appealing and its upper left corner should be aligned with the upper left corner of cell G13. IE 212: Computational Methods for Industrial Engineering Summer 2015 Homework #5: Writing sub procedures Thursday, July 23rd, 2015 Student Name: !TYPE YOUR NAME HERE!