Thursday, May 3, 2018

Include text in formulas

Include text in formulas

We often hear that you want to make data easier to understand by including text in your formulas, such as "2,347 units sold." To include text in your functions and formulas, surround the text with double quotes (""). The quotes tell Excel it's dealing with text, and by text, we mean any character, including numbers, spaces, and punctuation. Here's an example:

=A2&" sold "&B2&" units."

For this example, pretend the cells in column A contain names, and the cells in column B contain sales numbers. The result would be something like: Buchanan sold 234 units.

The formula uses ampersands (&) to combine the values in columns A and B with the text. Also, notice how the quotes don't surround cell B2. They enclose the text that comes before and after the cell.

Here's another example of a common task, adding the date to worksheet. It uses the TEXT and TODAY functions to create a phrase such as "Today is Friday, January 20."

="Today is " & TEXT(TODAY(),"dddd, mmmm dd.")

Let's see how this one works from the inside out. The TODAY function calculates today's date, but it displays a number, such as 40679. The TEXT function then converts the number to a readable date by first changing the number to text, and then using "dddd, mmmm dd" to control how the date appears--"Friday, January 20."

Make sure you surround "ddd, mmmm dd" date format with double quotes, and notice how the format uses commas and spaces. Normally, formulas use commas to separate the arguments—the pieces of data—they need to run. But when you treat commas as text, you can use them whenever you need to.

Finally, the formula uses the & to combine the formatted date with the words "Today is ". And yes, put a space after the "is."

No comments:

Post a Comment