求教各位大侠:一个刚入美国大学的研究生的作业题,急!
Homework Assignment 1This assignment uses the workbook: Assignment 1.xlsm
Date Brazil Real Australian Dollar Euro Bristish Pound Mexican Peso Canadian Dollar Swiss Franc Japanese Yen
6/23/2009 0.492 0.786 1.387 1.635 0.075 0.866 0.921 0.010
6/24/2009 0.505 0.794 1.408 1.646 0.075 0.870 0.937 0.011
6/25/2009 0.507 0.797 1.393 1.641 0.075 0.864 0.911 0.010
6/26/2009 0.515 0.803 1.399 1.637 0.076 0.866 0.914 0.010
6/29/2009 0.516 0.808 1.406 1.653 0.076 0.868 0.923 0.011
6/30/2009 0.511 0.808 1.408 1.657 0.076 0.865 0.924 0.010
7/1/2009 0.512 0.806 1.403 1.646 0.076 0.860 0.921 0.010
7/2/2009 0.517 0.808 1.414 1.648 0.076 0.870 0.930 0.010
7/3/2009 0.511 0.794 1.400 1.639 0.075 0.860 0.922 0.010
7/6/2009 0.512 0.797 1.398 1.633 0.076 0.862 0.920 0.010
7/7/2009 0.512 0.798 1.398 1.629 0.076 0.863 0.922 0.010
7/8/2009 0.501 0.789 1.392 1.614 0.075 0.857 0.918 0.011
7/9/2009 0.499 0.779 1.388 1.607 0.074 0.857 0.917 0.011
7/10/2009 0.498 0.783 1.402 1.634 0.074 0.860 0.927 0.011
7/13/2009 0.501 0.779 1.394 1.621 0.073 0.859 0.920 0.011
7/14/2009 0.506 0.783 1.398 1.623 0.073 0.869 0.923 0.011
7/15/2009 0.510 0.793 1.397 1.631 0.073 0.883 0.918 0.011
7/16/2009 0.517 0.803 1.411 1.642 0.074 0.899 0.931 0.011
7/17/2009 0.518 0.806 1.415 1.644 0.074 0.895 0.932 0.011
7/20/2009 0.519 0.802 1.410 1.634 0.075 0.898 0.929 0.011
7/21/2009 0.526 0.817 1.423 1.655 0.075 0.904 0.936 0.011
7/22/2009 0.527 0.818 1.423 1.646 0.075 0.906 0.938 0.011
Here we have one month’s worth of data giving the price of 1 unit of a foreign currency in dollars. For example, on June 23, 2009, one Euro cost 1.387 dollars.
You should write the VBA code (DO NOT DO THIS DIRECTLY IN EXCEL; YOU MUST DEVELOP VBA CODE) to do the following:
1. Generate a column that has the sum of the foreign currency values for that row. That is, it will tell you what it would cost in dollars to buy one unit of each of these currencies.
2. Generate a row at the end of the data giving an average of the values of each currency for the month. Thus, each currency will have an average value displaying. Also calculate the average of the Sum column.
3. Then, ask the user to enter the number of units of currency they want to buy. Your code should calculate the product of the number of units they specify and the monthly average of all currencies. You will then print out:
“To purchase ____ units of each foreign currency will cost you, on average, ______ dollars.” The blanks here should have the appropriate numbers.
If the user enters a negative number then the program should print “You must enter a positive number of units” and NOT do a calculation.
After you have finished this code, add 2 buttons, one that runs the macro to add the information described, and one that clears out the data you have added.
Check that your code contains:
DIM statements with appropriate variables.
Comments to explain what is happening.
Appropriate loops.
A conditional statement.
A request for user input.
Statements that print to the Excel spreadsheet.
You may choose to use an array.
Have fun!