Page 190 - Excel Progamming Weekend Crash Course
P. 190

k540629 ch13.qxd  9/2/03  9:34 AM  Page 165




                  Session 13 — Programming with Excel’s Built-In Functions               165

                 1. Create a new workbook.
                 2. Rename the first worksheet to “Loan Payment” so the worksheet tab displays that
                    name.
                 3. Insert the required labels in the target cells.
                 4. Insert the required PMT formula into the result cell.
                 5. Save the workbook.
                  One more task is required. The labels that are placed in the worksheet are wider than
               the default column width, which means that the width of the column must be increased to
               accommodate them. This is done using the column’s AutoFit method, which automatically
               increases the column width as needed to fit the data in the column. You’ll see this in the
               following code.
                  Figure 13-2 shows the worksheet created by this program. The result cell, C7, displays
               #DIV/0! because the input cells for the PMT formula are empty and the function cannot cal-
               culate properly. When values are entered in the three input cells, this display is replaced by
               the result.
































                    Figure 13-2 The worksheet created by the program in Listing 13-1

                          Percentages must be entered as decimals. For example, you would enter 0.05
                          for 5%.
                   Tip
                  Looking at Figure 13-2, there are several potential improvements that are immediately
               obvious, plus one other that may not be so obvious:
   185   186   187   188   189   190   191   192   193   194   195