Page 193 - Excel Progamming Weekend Crash Course
P. 193

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




                168                                                       Saturday Afternoon


                    Nonchanging Random Numbers                                   Continued

                            Next j
                        Next i

                        End Sub
                       Pass this procedure a range and a maximum value, and the code fills the range
                       with random values ranging from 0 to the specified maximum.




               Text Functions

               The text functions offered by Excel provide text-handling capabilities that are similar to
               those provided by the VBA language. Some of the functions even have the same names.
               Table 13-2 describes some of Excel’s text functions.


               Table 13-2 Description of Some of Excel’s Text Functions
               Function                     Description
               Clean(text)           Removes all nonprintable characters from text.

               Dollar(number,        Converts a number to currency format text with the specified
               decimals)             number of decimal places.

               Exact(text1, text2)   Returns True only if text1 and text2 match exactly
                                     (case-sensitive).
               Rept(text, num)       Repeats text the specified number of times.

               T(value)              If value is text, returns that text. If value is not text, returns
                                     an empty string.

               Trim(text)            Removes all spaces from text except for single spaces
                                     between words.

               Value(text)           Converts a text representation of a number to a numeric value.

                  Suppose you want to sum the values in cells A1:A10 and then display the result format-
               ted as currency (for example, “$1234.00”). The following formula does the trick:
                  =Dollar(Sum(A1:A10), 2)
   188   189   190   191   192   193   194   195   196   197   198