1. Create the Following Spreadsheet and Save It As Carloandss.Xls

Total Page:16

File Type:pdf, Size:1020Kb

1. Create the Following Spreadsheet and Save It As Carloandss.Xls

Sankaran Assignment 2 Due: 3/27/07 Total points: 10 1. Create the following spreadsheet and save it as CarLoanDSS.xls.

Name the sheet as Model. Name the cells as shown. Use proper formats ($ and %) where needed. Determine and enter the appropriate formulas for the Outputs in column B. When you finish entering the inputs, the correct outputs must automatically be calculated. (1 point)

2. Insert a new sheet with name Sensitivity. Type in the information as shown. C4 thru C7 must refer to the range names used in the Model sheet in B4 thru B7. (1 point)

3. Rename a third sheet as Explanation. The content should look as shown. 2

4. Create forms as shown below: (Forms a,b&d: 3points)

(a) When you click ‘Run the Application’ button in the Explanation sheet, the following form should appear.

Form name is frmOptions Assign names; optPayment to the first option button, optSensitivity to the second and optAmortization to the third button. When the first option is chosen, the following form opens.

(b) 3

Form name: frmInputs Name of the blank label area on the top left: lblExplanation. The program will insert appropriate text depending on the context. Name of the first blank textbox: txtPrice; 2nd textbox: txtDownPayment; 3rd txtInterest Name of option buttons: opt12, opt 24,…,opt60 When the OK button is clicked, a message box shows the monthly payment and total interest paid on the loan.

(c)

When you click OK above, it will take you back to form (a). If you choose the second option in (a), the following form will open.

(d)

Form name: frmSensitivity Name of options: optPrice, optDownPayment, optInterest, optTerm 4 You need only the optPrice option to work for this assignment. Prices should be simulated from half the input price to double the input price in steps of 10% of the user input price.

When OK in (d) is clicked, it will take you back to (b) with the specific explanation as shown in the label box.

When the OK button above is clicked, the following form of chart should show in a separate worksheet, “SensChart” [see (e) below] 5 (e)

The button, View Explanation, Sheet will take you back to the opening screen shown in Section 3. The button, View Sensitivity Table, should show the following table in a separate worksheet, “Sensitivity”.

Coding: A total of 5 points is allotted for writing the code to make the opening-screen/forms/ tables/charts shown above work as an integrated DSS application. 6

Insert a module to the VBA project and add the following: Declare the following variables as Public (at the top of the module code before any Subs). appOption: 1, 2 or 3, depending on which option user chooses in frmOptions sensOption: 1,2,3 or 4, depending on choice in frmSensitivity explanation: a string that will be used to customize label content in frmInputs. It varies depending on the appOption value.

Code a Sub with name Main and link it to the ‘Run the Application’ button in the opening screen.

Suggestions for the logic of the Sub Main:

Display frmOptions first. The btnOK_Click sub for the frmOptions should use an If or Case statement to check the value of appOption chosen by user.

If 1 was chosen, set explanation variable to,”Supply the following inputs and the application will calculate the monthly car payment, along with total interest paid.” Display the frmInputs and get user inputs. When user clicks OK button, read the user inputs and assign them to the appropriate ranges in the Model sheet. The model will automatically calculate the monthly payment and interest paid. Read off these values from the appropriate cell ranges and generate a message (4c).

If 2 was chosen, display the frmSensitivity. For this assignment, assume user will choose only the price option. The btnOK_Click sub for the frmSensitivity should set the value of the sensOption variable to 1 (since price is the first option on the form). Set the explanation variable to, “Select any of the following inputs. A sensitivity analysis of the monthly payment to this input will be performed.” Display the frmInputs. The explanation label area should say, “Enter the following inputs. Sensitivity analysis will be performed by varying the input you chose in earlier screen”. The user will now enter values of price, down payment, interest rate and term of loan. As described in the previous paragraph, when user clicks OK button, read the user inputs and assign them to the appropriate ranges in the Model sheet. Create a case statement to check the value of the sensOption variable. If it is 1, call a Sub (let us name it PriceSensitivity) that will do the price sensitivity analysis. Here is its suggested code.

Sub PriceSensitivity() Dim currentPrice As Currency, price As Currency Dim rowOffset As Integer, i As Integer Dim dataRange As Range, xRange As Range

With Worksheets("Sensitivity") .Visible = True .Activate End With

' Enter some labels and clear the sensitivity table from a previous run, if any. Range("C9") = "Price" With Range("B11") .Value = "Price" Range(.Offset(1, 0), .Offset(1, 2).End(xlDown)).ClearContents End With

' Capture the current price. 7 currentPrice = Range("Price") MsgBox "The price will be varied from half the current price " _ & "to double the current price, in increments of 10% of the " _ & "current price.", vbInformation, "Price range"

' For each possible price, enter it in the Price cell (in the Model sheet) ' and then store the corresponding payment and total interest values in the sensitivity sheet. rowOffset = 0 With Range("B11") For i = -5 To 10 price = currentPrice * (1 + i / 10) ' Do it only for prices at least as large as the down payment. If price >= Range("DownPay") Then rowOffset = rowOffset + 1 Range("Price") = price .Offset(rowOffset, 0) = Format(price, "$0.00") .Offset(rowOffset, 1) = Format(Range("Payment"), "$0.00") .Offset(rowOffset, 2) = Format(Range("TotInterest"), "$0.00") End If Next End With

' Restore the current price to the Price range (in the Model sheet). Range("Price") = currentPrice

' Set the ranges for the sensitivity chart and then update the chart. With Range("B11") Set dataRange = Range(.Offset(1, 1), .Offset(1, 2).End(xlDown)) Set xRange = Range(.Offset(1, 0), .End(xlDown)) End With Call UpdateSensChart("Price of Car", dataRange, xRange) End Sub

Sub UpdateSensChart(inputParameter As String, dataRange As Range, xRange As Range) ' This sub updates the (already-created) chart with the results of the sensitivity analysis.

With Charts("SensChart") .Visible = True .Activate .SetSourceData dataRange .SeriesCollection(1).Name = "Monthly payment" .SeriesCollection(2).Name = "Total interest" .SeriesCollection(1).XValues = xRange .Axes(xlCategory).AxisTitle.Caption = inputParameter .ChartTitle.Text = "Sensitivity to " & inputParameter .Deselect End With End Sub

Recommended publications