18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating Formulas That Manipulate Text 12<br />

Displaying formatted values as text<br />

The TEXT function enables you to display a value in a specific number format. Figure 12.2 shows a simple<br />

worksheet. The formula in cell D3 is<br />

=”The net profit is “ & B3<br />

FIGURE 12.2<br />

The formula in D3 doesn’t display the formatted number.<br />

This formula essentially combines a text string with the contents of cell B3 and displays the result. Note,<br />

however, that the contents of B3 are not formatted in any way. You might want to display the contents of B3<br />

using a Currency number format.<br />

NOTE<br />

Contrary to what you might expect, applying a number format to the cell that contains the formula<br />

has no effect. This is because the formula returns a string, not a value.<br />

Here’s a revised formula that uses the TEXT function to apply formatting to the value in B3:<br />

=”The net profit is “ & TEXT(B3,” $#,##0”)<br />

This formula displays the text along with a nicely formatted value:<br />

The net profit is $230,794.<br />

The second argument for the TEXT function consists of a standard Excel number format string. You can<br />

enter any valid number format code for this argument.<br />

The preceding example uses a simple cell reference (B3). You can, of course, use an expression instead.<br />

Here’s an example that combines text with a number resulting from a computation:<br />

=”Average Expenditure: “& TEXT(AVERAGE(A:A),”$#,##0.00”)<br />

This formula might return a string such as Average Expenditure: $7,794.57.<br />

Here’s another example that uses the NOW function (which returns the current date and time). The TEXT<br />

function displays the date and time, nicely formatted.<br />

=”Report printed on “&TEXT(NOW(),”mmmm d, yyyy at h:mm AM/PM”)<br />

The formula might display the following:<br />

CROSS-REF<br />

Report printed on March 22, 2007 at 3:23 PM.<br />

Refer to Chapter 24 for details on Excel number formats.<br />

211

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

Saved successfully!

Ooh no, something went wrong!