FALL 2018 - CS 146 (LAB6) EDUCATIONAL GOALS OF THIS LAB Verify that students can 1. Define subs. 2. Declare variables and assign them values. 3. Perform some simple mathematical calculation. 4. Use the different selection statement 5. Use Loop. 6. Use Message box and Input box. 7. Use worksheets and workbooks operations. 8. Use Chart. LAB DETAILS Download the excel file called Movies.xlsx, which contains information about different movies. You are going to answer five different problems about such file. The description for every problem is described in the next sections. Open the file, then choose the file menu and pick the save as option. Save the file as YOURNAME.xlms, replace YOURNAME with your Actual Real Name. (If you are working on the lab desktop then make sure to save your data under your personal drive, (don t save your file on your desktop or my documents). However, if you are using your laptop then make sure to save your file under a cloud storage application (Dropbox, GoogleDrive, OneDrive, etc. (If you don t know them, then ask me or your TA)). BACKGROUND The file that you donwloaded above contains infromation about 24 movies. For each movie you have the following infromation stored into column C to G: The movie s number. The movie s title. The movie s title. The movie s distributor The movie s box office (USD MM) The movie s rating
The following is a screenshot of the file data. PROBLEM 1 Define a sub called CreateThreeNewExcelFiles. The code inside the sub will perform the following operations: 1. Create a new workbook 2. Save the new workbook you created in step 1 under the name 20th Century Fox.xlsx. 3. Create another new workbook 4. Save the new workbook you created in step 3 under the name Restricted Movies.xlsx. 5. Create another new workbook 6. Save the new workbook you created in step 5 under the name Distributors Total Sales.xlsx. 7. Show the number of opened workbooks in a message box.
8. Now write inside the second workbook (the one which has the name 20th Century Fox.xlsx) the following: a. Inside the cell D1 write Movie Title b. Inside the cell E1 write Box Office Sales 9. Now write inside the third workbook (the one which has the name Restricted Movies.xlsx) the following: a. Inside the cell D1 write Movie Title 10. Now write inside the fourth workbook (the one which has the name Distributors Total Sales.xlsx) the following: a. Inside the cell D1 write Distributor b. Inside the cell E1 write Total Sales Test your Sub 2. Now draw a button inside the cells I11 to L13. 3. Associate the button with the sub/marco CreateThreeNewExcelFiles 4. Give the button the caption (Text inside the button) Create Three New Excel Files PROBLEM 2 Before you start working on this problem, you have to make sure that you answer the first problem. Define a sub called Fill20thCenturyFoxFile. The code inside the sub will perform the following operations: 1. Go over all the movies (what do you need here?) from the first sheet in the workbook (that holds your name) to the first sheet in the first workbook you created in problem (20th Century Fox.xlsx) based on the following condition/criteria: a. Test if the movie is distributed by 20th Century Fox, if it is, then: i. Copy the title of the movie to the column D in the destination sheet. ii. Copy the Box Office Sales of the movie to the column E in the destination sheet.
iii. Don t leave any gap between the data inside the destination sheet, and you should start from row 2 in the first sheet of the second workbooks (20th Century Fox.xlsx). 2. Close the workbook 20th Century Fox.xlsx. You should be able to see the following result at sheet1 of the second workbook. Test your Sub 2. Now draw a button inside the cells I15 to L17. 3. Associate the button with the sub/marco Fill20thCenturyFoxFile 4. Give the button the caption (Text inside the button) Fill 20 th Century Fox File PROBLEM 3 Before you start working on this problem, you have to make sure that you answer the first problem. Define a sub called FillRestrictedMovies. The code inside the sub will perform the following operations: 1. Go over all the movies (what do you need here?) from the first sheet in the workbook (that holds your name) to the first sheet in the second workbook you created in problem (Restricted Movies.xlsx) based on the following condition/criteria: a. Test if the movie is classified as restricted (R), if it is, then: i. Copy the title of the movie to the column D in the destination sheet.
ii. Don t leave any gap between the data inside the destination sheet, and you should start from row 2 in the first sheet of the second workbooks (Restricted Movies.xlsx). You should be able to see the following result at sheet1 of the third workbook. Test your Sub 2. Now draw a button inside the cells I19 to L21. 3. Associate the button with the sub/marco FillRestrictedMovies 4. Give the button the caption (Text inside the button) Fill Restricted Movies PROBLEM 4 Before you start working on this problem, you have to make sure that you answer the first problem. This is a sub that has a long code, but there is a lot of repetition there. Define a sub called DistributorsTotalSales. The code inside the sub will perform the following operations: 1. Now write inside the fourth workbook (the one which has the name Distributors Total Sales.xlsx) the following: a. Inside the cell D2 write Disney b. Inside the cell D3 write Lionsgate c. Inside the cell D4 write Warner Bros
d. Inside the cell D5 write Paramount e. Inside the cell D6 write 20th Century Fox f. Inside the cell D7 write Sony g. Inside the cell D8 write Universal 2. Go over all the movies (what do you need here?) from the first sheet in the workbook (that holds your name) to the fourth sheet in the first workbook you created in problem (Distributors Total Sales.xlsx) based on the following condition/criteria: a. Test if the movie s distributor is Disney, if it is, then: distributed by Disney. ii. After you find the total, then put the total into E2 of the first sheet of b. Test if the movie s distributor is Lionsgate, if it is, then: distributed by Lionsgate. ii. After you find the total, then put the total into E3 of the first sheet of c. Test if the movie s distributor is Warner Bros, if it is, then: distributed by Warner Bros. ii. After you find the total, then put the total into E4 of the first sheet of d. Test if the movie s distributor is Paramount, if it is, then: distributed by Paramount. ii. After you find the total, then put the total into E5 of the first sheet of e. Test if the movie s distributor is 20th Century Fox, if it is, then: distributed by 20th Century Fox. ii. After you find the total, then put the total into E6 of the first sheet of f. Test if the movie s distributor is Sony, if it is, then: distributed by Sony. ii. After you find the total, then put the total into E7 of the first sheet of g. Test if the movie s distributor is Universal, if it is, then:
distributed by Universal. ii. After you find the total, then put the total into E8 of the first sheet of You should be able to see the following result at sheet1 of the fourth workbook 3. Now create a chart based on the data (D2:E8) stored inside the first sheet of the workbook called The chart has the following properties a. The type of the chart is a clustered column chart. b. It is located inside a separate sheet. c. Add a data label for the data inside the chart d. It has a title called Distributors Totals Now, you should be able to see the following chart.
Test your Sub 2. Now draw a button inside the cells I23 to L25. 3. Associate the button with the sub/marco DistributorsTotalSales 4. Give the button the caption (Text inside the button) Distributors Total Sales PROBLEM 5 Before you start working on this problem, you have to make sure that you answer the first problem. Define a sub called CloseAllFiles. The code inside the sub will perform the following operations: 1. Save the second workbook (20th Century Fox.xlsx). 2. Close the second workbook (20th Century Fox.xlsx). 3. Save the third workbook (Restricted Movies.xlsx). 4. Close the third workbook (Restricted Movies.xlsx). 5. Save the fourth workbook (Distributors Total Sales.xlsx). 6. Close the fourth workbook (Distributors Total Sales.xlsx). 7. Close the first workbook (YOURNAME.xlms). Test your Sub 2. Now draw a button inside the cells I27 to L29. 3. Associate the button with the sub/marco CloseAllFiles 4. Give the button the caption (Text inside the button) Close All Files LAB DUE TIME 1. Save your work (Make sure to name the file with xlms extension, otherwise, all your work will be lost)
2. Upload only the file called YOURNAME.xlms to Blackboard under lab6. The due date for that is Monday 12/3/2018 at 11:59pm. No late work will be accepted