18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Creating Formulas That Manipulate Text 12<br />

The formulas in column D graphically depict the sales numbers in column B by displaying a series of characters<br />

in the Wingdings font. This example uses character code 61 (an equal sign), which appears on-screen<br />

as a small floppy disc the Wingdings font. A formula using the REPT function determines the number of<br />

characters displayed. The formula in cell D2 is:<br />

=REPT(“=”,B2/100)<br />

Assign the Wingdings font to cells D2, and then copy the formulas down the column to accommodate all<br />

the data. Depending on the numerical range of your data, you may need to change the scaling. Experiment<br />

by replacing the 100 value in the formulas. You can substitute any character you like for the equal sign<br />

character in the formula to produce a different character in the chart.<br />

ON the CD-ROM<br />

The workbook shown in Figure 12.3 also appears on the companion CD-ROM. The file is<br />

named text histogram.xlsx.<br />

Padding a number<br />

You’re probably familiar with a common security measure (frequently used on printed checks) in which<br />

numbers are padded with asterisks on the right. The following formula displays the value in cell A1, along<br />

with enough asterisks to make a total of 24 characters:<br />

=(A1 & REPT(“*”,24-LEN(A1)))<br />

If you’d prefer to pad the number with asterisks on the left instead, use this formula:<br />

=REPT(“*”,24-LEN(A1))&A1<br />

The formula below displays 12 asterisks on both sides of the number.<br />

=REPT(“*”,12)&A1&REPT(“*”,12)<br />

The preceding formulas are a bit deficient because they don’t show any number formatting. This revised<br />

version displays the value in A1 (formatted), along with the asterisk padding on the right:<br />

=(TEXT(A1,”$#,##0.00”)&REPT(“*”,24-LEN(TEXT(A1,”$#,##0.00”))))<br />

Figure 12.4 shows this formula in action.<br />

FIGURE 12.4<br />

Using a formula to pad a number with asterisks.<br />

You can also pad a number by using a custom number format. To repeat the next character in that format<br />

until it fills the column width, include an asterisk (*) in the custom number format code. For example, use<br />

this number format to pad the number with dashes:<br />

$#,##0.00*-<br />

213

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!