Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Combining Numbers and Text in a Cell.
Written by Allen Wyatt (last updated December 28, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
Many times, I want a description for my data. One approach is to put the description—a simple text string—near the cell containing the data that needs describing. For instance, a numeric value could go in cell B3, and the unit description in cell C3, which read together may be something like "3.27 miles."
Another approach is to put the description text and the numeric value together. Creating text strings easily accomplishes this feat. Here's a very simple example that displays "1 + 1 is 2."
="1 + 1 is " & 1+1
The quotation marks are important. By making the text string part of a formula, you can combine the description and the value within one cell.
The disadvantage of this approach is formatting the value takes more effort; since the result is a text string, numeric cell formatting does not apply. For example, consider the above formula and the need to display two decimal places. One might naturally display the Format Cell dialog box and then choose a Number format that has two decimal places, but the results would not change. (Remember, the result of the formula is text, not a number.)
To affect the value formatting, use the TEXT function. To force the above results to display the value to two decimal places, use the following formula.
="1 + 1 is " & TEXT(1+1, "0.00")
The different formats you can use with the TEXT function have been covered in other issues of ExcelTips, and you can also find more info in Excel's Help system. Here's an example that displays "Today is " along with today's date. Enter the following formula in some cell:
="Today is " & TEXT(NOW(),"dddd, mmm dd, yyyy")
Again, the quotation marks are important, as you are constructing a text string.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9306) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Combining Numbers and Text in a Cell.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
When working with names or a different series of words, you may need to pull the initial letters from each word in the ...
Discover MoreNeed to figure out the lowest score in a range of scores? Here's the formulas to get the information you need.
Discover MoreExcel provides a variety of tools that allow you to perform operations on your data based upon the characteristics of ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-12-28 18:23:11
Mitchell Bender
Hi Allen,
You could also use a custom format similar to #.00 & " miles" which would obviate the need for the second column and, perhaps more importantly, allow for simple numeric entry or a formula without having to format text to look like a number. The user would need to ensure the column was made wide enough to display the likely maximum width of an answer.
Cheers,
Mitchell
2022-12-28 08:11:20
Kiwerry
P.S. One major difference between the two approaches becomes apparent when copying is used in conjunction with ' Paste Special '. Using my example below, copying each of the cells, and then pasting contents only into two different cells gives completely different results:
TEXT Function:
It's 14:05:00 on Wednesday, Dec 28, 2022
Custom formatting:
44923.5868039352
2022-12-28 08:02:21
Kiwerry
@Erik: thanks for mentioning the Ctrl-1 shortcut to open the cell format window.
Allen's approach will work the same way as yours in the '=NOW()' example. The following two approaches each yielded the same result in MS365 Excel:
Formula ' =NOW() ' in a cell, which was then custom formatted with
' "It's "hh:mm:ss" on "dddd, mmm dd, yyyy '
Formula ' ="It's "&TEXT(NOW(),"hh:mm:ss"" on ""dddd, mmm dd,yyyy") ' in a cell.
Notes
The single apostrophe & space combination is used to indicate what was entered in Excel and should not be entered as well, and
the inclusion of seconds in the time format allowed easy checking that the result shown in both cells is the same when the sheet is recalculated.
Which of the two methods (the TEXT() function or custom formatting) is best suited to particular circumstances depends on personal preference. Factors which may play a role and which occur to me follow. Comments with additional factors are welcome.
The TEXT() method results in a more unwieldy formula. In the example above this is not much of a problem, but if the formula to be evaluated to get the result is itself complicated, the resulting formula with formatting is even longer, which makes it more difficult to read and may mean that it becomes easier to make mistakes; in this case, custom formatting completely separates the function from the formatting, allowing the user to concentrate on one aspect at a time.
Copying the cell to a blank workbook: no problems encountered. The custom formatting is copied to the new workbook and is available for use there. BTW An export/import option in the Custom tab of the Format Cells dialogue would be a very handy addition to the currently available methods of setting up templates or simply copying cells and/or worksheets from one workbook to another.
2019-07-04 02:59:29
SteveJez
Mohammed,
Add the 2 cells together, such as C2=A2+B2
then custom format the cell (Ctrl 1) Number - Custom & use
dd/mm/yyyy hh:mm:ss AM/PM as the format (see Figure 1 below)
HTH
Figure 1. Date Time Custom Format
2019-07-03 05:06:53
Mohammed Nufail
Hi. I have some data in excel. Date is in separate cell: Eg; (16/06/2019) . Time is in separate cell. Eg; (9:11:45 AM)
Need to combine together in to once cell. But when converted it comes with numbers only.
Can you please fix this
2019-03-30 16:59:37
Erik
In some cases, custom formatting might work better. For example, you can put "=NOW()" in a cell and it will remain a value. Then, highlight that cell, open the "Format Cells" window (ctrl-1 is one easy way), select the "Number" tab, and set the "Category:" to "Custom". Put this in the "Type:" box (including quotes):
"today is "dddd, mmm dd, yyyy
This method is works well for other instances, for example showing units. But is not ideal in cases where the text might frequently change, for example the 1+1 example.
2019-03-30 07:52:14
David R
To retain the cell as a numeric value and thence be able to affect the number of decimal places or use it as a number in a formula, etc, try custom formatting, ie "1+1=" # or some such. I use this a lot when I want to the number to be associated with a descriptive word like "Extra" or "Total = " or "Hold for tomorrow" or "George's share".
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments