Excel adding numbers with text

Excel for Microsoft 365 Excel 2021 Excel 2019 Excel 2016 Excel 2013 Excel 2010 Excel 2007 More…Less

Let’s say you need to create a grammatically correct sentence from several columns of data to prepare a mass mailing. Or, maybe you need to format numbers with text without affecting formulas that use those numbers. In Excel, there are several ways to combine text and numbers.

Use a number format to display text before or after a number in a cell

If a column that you want to sort contains both numbers and text—such as Product #15, Product #100, Product #200—it may not sort as you expect. You can format cells that contain 15, 100, and 200 so that they appear in the worksheet as Product #15, Product #100, and Product #200.

Use a custom number format to display the number with text—without changing the sorting behavior of the number. In this way, you change how the number appears without changing the value.

Follow these steps:

  1. Select the cells that you want to format.

  2. On the Home tab, in the Number group, click the arrow .
    Dialog Box Launcher in Number group

  3. In the Category list, click a category such as Custom, and then click a built-in format that resembles the one that you want.

  4. In the Type field, edit the number format codes to create the format that you want.

    To display both text and numbers in a cell, enclose the text characters in double quotation marks (» «), or precede the numbers with a backslash ().

    NOTE: Editing a built-in format does not remove the format.

To display

Use this code

How it works

12 as Product #12

«Product # » 0

The text enclosed in the quotation marks (including a space) is displayed before the number in the cell. In the code, «0» represents the number contained in the cell (such as 12).

12:00 as 12:00 AM EST

h:mm AM/PM «EST»

The current time is shown using the date/time format h:mm AM/PM, and the text «EST» is displayed after the time.

-12 as $-12.00 Shortage and 12 as $12.00 Surplus

$0.00 «Surplus»;$-0.00 «Shortage»

The value is shown using a currency format. In addition, if the cell contains a positive value (or 0), «Surplus» is displayed after the value. If the cell contains a negative value, «Shortage» is displayed instead.

Combine text and numbers from different cells into the same cell by using a formula

When you do combine numbers and text in a cell, the numbers become text and no longer function as numeric values. This means that you can no longer perform any math operations on them.

To combine numbers, use the CONCATENATE or CONCAT, TEXT or TEXTJOIN functions, and the ampersand (&) operator.
 

Notes: 

  • In Excel 2016, Excel Mobile, and Excel for the web, CONCATENATE has been replaced with the CONCAT function. Although the CONCATENATE function is still available for backward compatibility, you should consider using CONCAT, because CONCATENATE may not be available in future versions of Excel.

  • TEXTJOIN combines the text from multiple ranges and/or strings, and includes a delimiter you specify between each text value that will be combined. If the delimiter is an empty text string, this function will effectively concatenate the ranges. TEXTJOIN is not available in Excel 2013 and previous versions.

Examples

See various examples in the figure below.

Look closely at the use of the TEXT function in the second example in the figure. When you join a number to a string of text by using the concatenation operator, use the TEXT function to control the way the number is shown. The formula uses the underlying value from the referenced cell (.4 in this example) — not the formatted value you see in the cell (40%). You use the TEXT function to restore the number formatting.

Examples pf combining text and numbers

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

See Also

  • CONCATENATE function

  • CONCAT function

  • TEXT function

  • TEXTJOIN function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Содержание

  1. Convert numbers stored as text to numbers
  2. 1. Select a column
  3. 2. Click this button
  4. 3. Click Apply
  5. 4. Set the format
  6. Other ways to convert:
  7. 1. Insert a new column
  8. 2. Use the VALUE function
  9. 3. Rest your cursor here
  10. 4. Click and drag down
  11. Combine text and numbers
  12. Use a number format to display text before or after a number in a cell
  13. Combine text and numbers from different cells into the same cell by using a formula
  14. Examples
  15. Need more help?
  16. Number Formatting in Excel — All You Need to Know
  17. How to create a custom number format in Excel
  18. Basics
  19. Syntax
  20. Placeholders and the Cheat Sheet
  21. Common Practices
  22. Display and control of the first digit and decimals
  23. Add text to numbers
  24. Hide value
  25. Replace zeroes with dashes
  26. Start with zeroes
  27. Dealing with thousands, millions, and more
  28. Display numbers as phone numbers
  29. Showing Month and Weekday Names
  30. Come in Colors Everywhere
  31. Conditions

Convert numbers stored as text to numbers

Numbers that are stored as text can cause unexpected results, like an uncalculated formula showing instead of a result. Most of the time, Excel will recognize this and you’ll see an alert next to the cell where numbers are being stored as text. If you see the alert, select the cells, and then click to choose a convert option.

Check out Format numbers to learn more about formatting numbers and text in Excel.

If the alert button is not available, do the following:

1. Select a column

Select a column with this problem. If you don’t want to convert the whole column, you can select one or more cells instead. Just be sure the cells you select are in the same column, otherwise this process won’t work. (See «Other ways to convert» below if you have this problem in more than one column.)

2. Click this button

The Text to Columns button is typically used for splitting a column, but it can also be used to convert a single column of text to numbers. On the Data tab, click Text to Columns.

3. Click Apply

The rest of the Text to Columns wizard steps are best for splitting a column. Since you’re just converting text in a column, you can click Finish right away, and Excel will convert the cells.

4. Set the format

Press CTRL + 1 (or + 1 on the Mac). Then select any format.

Note: If you still see formulas that are not showing as numeric results, then you may have Show Formulas turned on. Go to the Formulas tab and make sure Show Formulas is turned off.

Other ways to convert:

You can use the VALUE function to return just the numeric value of the text.

1. Insert a new column

Insert a new column next to the cells with text. In this example, column E contains the text stored as numbers. Column F is the new column.

2. Use the VALUE function

In one of the cells of the new column, type =VALUE() and inside the parentheses, type a cell reference that contains text stored as numbers. In this example it’s cell E23.

3. Rest your cursor here

Now you’ll fill the cell’s formula down, into the other cells. If you’ve never done this before, here’s how to do it: Rest your cursor on the lower-right corner of the cell until it changes to a plus sign.

4. Click and drag down

Click and drag down to fill the formula to the other cells. After that’s done, you can use this new column, or you can copy and paste these new values to the original column. Here’s how to do that: Select the cells with the new formula. Press CTRL + C. Click the first cell of the original column. Then on the Home tab, click the arrow below Paste, and then click Paste Special > Values.

If the steps above didn’t work, you can use this method, which can be used if you’re trying to convert more than one column of text.

Select a blank cell that doesn’t have this problem, type the number 1 into it, and then press Enter.

Press CTRL + C to copy the cell.

Select the cells that have numbers stored as text.

On the Home tab, click Paste > Paste Special.

Click Multiply, and then click OK. Excel multiplies each cell by 1, and in doing so, converts the text to numbers.

Press CTRL + 1 (or + 1 on the Mac). Then select any format.

Источник

Combine text and numbers

Let’s say you need to create a grammatically correct sentence from several columns of data to prepare a mass mailing. Or, maybe you need to format numbers with text without affecting formulas that use those numbers. In Excel, there are several ways to combine text and numbers.

Use a number format to display text before or after a number in a cell

If a column that you want to sort contains both numbers and text—such as Product #15, Product #100, Product #200—it may not sort as you expect. You can format cells that contain 15, 100, and 200 so that they appear in the worksheet as Product #15, Product #100, and Product #200.

Use a custom number format to display the number with text—without changing the sorting behavior of the number. In this way, you change how the number appears without changing the value.

Follow these steps:

Select the cells that you want to format.

On the Home tab, in the Number group, click the arrow .

In the Category list, click a category such as Custom, and then click a built-in format that resembles the one that you want.

In the Type field, edit the number format codes to create the format that you want.

To display both text and numbers in a cell, enclose the text characters in double quotation marks (» «), or precede the numbers with a backslash ().

NOTE: Editing a built-in format does not remove the format.

12 as Product #12

The text enclosed in the quotation marks (including a space) is displayed before the number in the cell. In the code, «0» represents the number contained in the cell (such as 12).

12:00 as 12:00 AM EST

The current time is shown using the date/time format h:mm AM/PM, and the text «EST» is displayed after the time.

-12 as $-12.00 Shortage and 12 as $12.00 Surplus

$0.00 «Surplus»;$-0.00 «Shortage»

The value is shown using a currency format. In addition, if the cell contains a positive value (or 0), «Surplus» is displayed after the value. If the cell contains a negative value, «Shortage» is displayed instead.

Combine text and numbers from different cells into the same cell by using a formula

When you do combine numbers and text in a cell, the numbers become text and no longer function as numeric values. This means that you can no longer perform any math operations on them.

To combine numbers, use the CONCATENATE or CONCAT, TEXT or TEXTJOIN functions, and the ampersand (&) operator.

In Excel 2016, Excel Mobile, and Excel for the web, CONCATENATE has been replaced with the CONCAT function. Although the CONCATENATE function is still available for backward compatibility, you should consider using CONCAT, because CONCATENATE may not be available in future versions of Excel.

TEXTJOIN combines the text from multiple ranges and/or strings, and includes a delimiter you specify between each text value that will be combined. If the delimiter is an empty text string, this function will effectively concatenate the ranges. TEXTJOIN is not available in Excel 2013 and previous versions.

Examples

See various examples in the figure below.

Look closely at the use of the TEXT function in the second example in the figure. When you join a number to a string of text by using the concatenation operator, use the TEXT function to control the way the number is shown. The formula uses the underlying value from the referenced cell (.4 in this example) — not the formatted value you see in the cell (40%). You use the TEXT function to restore the number formatting.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

Number Formatting in Excel — All You Need to Know

by Adam | Apr 2, 2018 | Blog

If you used Excel in any shape or form, there is a pretty good chance that you’ve used the formatting and number formatting features. Formatting options like number, currency, percentage, date and time values are easily accessible to users. However, that’s not all there is in the world of text and number formatting. Going down the rabbit hole, custom formatting can help you fully configure Excel’s built-in settings for formatting.

The main advantage of this approach is that you can alter the look of your data without changing the actual values. This means that you do not need to use additional spaces or formulas to create the layout you want and preserve the raw data.

If you want to modify your data anyways, or need to change a value inside a formula, you can use the TEXT function with all custom formatting syntax we are going to cover in this article. It should be noted that the TEXT function returns a text, and the return value cannot be used in mathematical calculations. If you do, you will receive a #VALUE! error. In this article we’re going to be using a workbook template. You can download it below.

How to create a custom number format in Excel

  1. Select the cell to be formatted and press Ctrl+1 to open the Format Cells dialog. An alternative way to do is by right-clicking the cell and then going to Format Cells > Number Tab.
  2. Under Category, select Custom.
  3. Type in the format code into the Type
  4. Click OK to save your changes.

Note: In Format Cells dialog you can modify the built-in format codes by selecting the format you want to modify in its own category (i.e. Currency > ($1,234.10)) and then selecting Custom Category. Don’t worry, Excel will not let you delete built-in formats.

Basics

Syntax

The format code has 4 sections separated by semicolons.

POSITIVE; NEGATIVE; ZERO; TEXT

These sections are optional,

  • If a code contains only 1 section, the format is applied to all number types — positive, negative and zero.
  • If a code contains 2 sections, the first section is used for positive and zero values, while the second section is applied to negative values.
  • If a code contains 3 sections, the first is for positive, the second is for negative, and the third is for zero.
  • A code only affects text values if all sections exist.

Default format type in Excel is called General. You can type General for sections you don’t want formatted. Make sure you use a minus sign (-) with General if you want to skip negative values.

If you want to completely hide a type, leave it blank after the semicolon. For example; to hide 0 values, General;-General;;General

Placeholders and the Cheat Sheet

Placeholder Description Raw Value Format Code Formatted Value
General Default format 1234.567 General 1234.567
# Placeholder for digits (numbers) and does not add any leading zeroes. 1234.567 #####.#### 1234.567
0 Placeholder for digits (numbers) and add any leading zeroes. 1234.567 00000.0000 01234.5670
? Placeholder for digits (numbers) and add space characters. 1234.567 . 1234.567
. Placeholder for the decimal place. 1234.567 0.00 1234.57
_ Adds a blank space, to the width of the following character. You can use in combination with parentheses to add left and right indents, _( and _) respectively. 99 _(#_);(#) 99
-25 (25)
58 58
12 12
-71 (71)
36 36
* Repeats the character after asterisk until the width of the cell is filled. 66 0 *! 66 .
Full Name @ *_ Full Name ____
% Convert value to a percentage with % sign 0.12 % 12%
, Thousands separator 1234.567 #, 1
12345678 #, 12,346
12345678 #,###, 12,346
12345678 #,, 12
E Scientific notation format. Requires a ‘+’ symbol after, and a digit placeholder before and after. 1234.567 0.00E+00 1.23E+03
/ Represents fractions 1.234 # ##/## 1 11/47
1.234 # 000/000 1 117/500
1.234 ##/## 58/47
«» Text placeholder for multiple characters 1234.567 #,##0 «km/h» 1,235 km/h
Good «Result is: «@ Result is: Good
Text placeholder for single character 1234 #.00, K 1.23 K
1234567 #.00,, M 1.23 M
@ Placeholder for text Bad «Result is: «@ Result is: Bad
[color] Change Color of value. Options: [Black], [Green], [White], [Blue], [Magenta], [Yellow], [Cyan], [Red] 1234.567 [Green]#,##0.00_);
[Red](#,##0.00);
[Blue]0.00_);
[Magenta]@
1,234.57
-1234.567 (1,234.57)
0 0.00
This is a text This is a text

Common Practices

Display and control of the first digit and decimals

Decimal places in the code are indicated with a period (.). Number of zeroes after the period (.) define the number of decimal places. For example,

  • 0 — display 1 decimal place
  • 00 — display 2 decimal places

If the number has more decimals than the decimal placeholders defined, the number will be rounded to the nearest number of placeholders.

Raw Value Format Code Formatted Value
123.4 0.0 123.4
123.4 0.00 123.40
123.45 0.00 123.45
123.45 0.00 123.46
123.456 0.0 123.5

Alternatively, hash (#) and question mark (?) symbols can be used as decimal places. However, because any missing decimal places will be filled with zeroes, using zeroes instead will be easier to read.

Raw Value Format Code Formatted Value
0.25 0.00 0.25
0.25 #.## .25
123 0.00 123.0
123 #. 123.00
123 #.## 123.

Add text to numbers

Custom text can be added to the beginning or the end of a value. Text and characters should be added inside quotes («») and backslashes (). You can use backslash () to add single character.

Raw Value Format Code Formatted Value
123.4 0.0 «ft.» 123.4 ft.
123.4 0.00 l 123.40 l
123.45 «Approx.» 0 Approx. 123
123.45 «Result:» 0.00 C Result: 123.46 C
Bad «Result is: «@ Result is: Bad

Quotation marks or backslashes are not necessary for spaces ( ) and some special characters.

Symbol Description
+ and — Plus and minus signs
( ) Left and right parenthesis
: Colon
^ Caret
Apostrophe
Curly brackets
Less-than and greater than signs
= Equal sign
/ Forward slash
! Exclamation point
& Ampersand
Tilde
Space character

Below are some special characters you can use by copying or typing in the numerical code while pressing down Alt button.

Symbol Code Description
Alt+0153 Trademark
© Alt+0169 Copyright symbol
° Alt+0176 Degree symbol
± Alt+0177 Plus-Minus sign
µ Alt+0181 Micro sign

Hide value

If you leave any number of sections blank, the value of those sections will be hidden. A section should always be separated (defined) by a semicolon (;). Here are some examples,

Raw Value Format Code Formatted Value
1 0;;0; 1
-2 0;;0;
0 0;;0; 0
Some text 0;;0;
1 ;(0);;@
-2 ;(0);;@ (2)
0 ;(0);;@
Some text ;(0);;@ Some Text
1 ;;;
-2 ;;;
0 ;;;
Some text ;;;

Replace zeroes with dashes

Zeroes can make data tables look more complicated than they actually are. You can hide them completely by using the previous method, or replace them with any character of your choice. Dash (-) is a common example. All you need to is place a dash into the ‘Zero section’.

Raw Value Format Code Formatted Value
0 General;-General;»-«;General
3487 General;-General;»-«;»-«
12 #,##0.00;(#,##0.00);»-«;

Start with zeroes

If try to enter a ZIP number that starts with 0, the leading zeroes will be removed automatically by Excel. To keep the leading zeros, use zero (0) placeholder for whole numbers.

Raw Value Format Code Formatted Value
10010 00000 10010
3487 00000 03487
12 00000 00012
0 00000 00000
123456 00000 123456

Dealing with thousands, millions, and more

You may have noticed that ‘0.0’ or other simple formats do not separate thousands or millions. Adding a comma into the code will insert commas to separate numbers.

Raw Value Format Code Formatted Value
1234 #,##0 1,234
123456 #,##0 123,456
12345678 #,##0 12,345,678
123456.789 #,##0 123,457
123456.789 #,##0.0 123,456.8

There must be placeholders for numbers smaller than one thousand, otherwise such values will be hidden. This behavior allows us to round and format our value to show only thousands or millions.

Raw Value Format Code Formatted Value
1234 #, 1
123456 #, 123
12345678 #, 12345
12345678 #,, 12
123456 #.0, K 123.5 K
12345678 #.0,, M 12.3 M

Display numbers as phone numbers

Phone numbers can be hard to read without any separators. Custom Number Format Codes is perfect for this job. The hash (#) character should be your best bet to avoid any redundancy of placeholders (0, ?)

Raw Value Format Code Formatted Value
1234567890 (###) ###-#### (123) 456-7890
12345678900 (###) #### #### (123) 4567 8900
1234567890 (##) #### #### (12) 3456 7890

Showing Month and Weekday Names

Date and time values are stored as numbers in Excel. When you enter a date, Excel automatically converts it into a numerical value, and then formats the cell.

Before jumping into the code, let’s review some basics. Formatting code has special placeholders for date and time formatting that behave a bit differently. For example, while m and mm will show month as a number, mmm and mmmm will show as a text string. Below are some examples.

Raw Value Format Code Formatted Value
4/1/2018 m 4
4/1/2018 mm 04
4/1/2018 mmm Apr
4/1/2018 mmmm April
4/1/2018 mmmmm A
4/1/2018 d 1
4/1/2018 dd 01
4/1/2018 ddd Sun
4/1/2018 dddd Sunday
4/1/2018 11:59:31 PM dddd, mmmm dd, yyyy h:mm AM/PM;@ Sunday, April 01, 2018 11:59 PM

Here is the full list of options for the date 4/1/2018 23:59:31 ,

Format Code Description Example (4/1/2018 23:59:31)
yyyy Displays the year as a four-digit number. 2018
yy Displays the year as a two-digit number. 18
m Displays the month as a number without a leading zero. 4
mm Displays the month with a leading zero. 04
mmm Displays the month as text, as an abbreviation. Apr
mmmm Displays the month as text. April
mmmmm Displays the month as a single character A
d Displays the day as a number, without a leading zero. 1
dd Displays the day as a number, with a leading zero. 01
ddd Displays the day as a day of the week, as an abbreviation. Sun
dddd Displays the day as a day of the week, without abbreviation Sunday
h Displays the hour without a leading zero. 23
hh Displays the hour with a leading zero. 23
[h] Displays elapsed time in hours (to be used when the time value exceeds 24 hours). 1036607
m Displays the minute without a leading zero. 4
mm Displays the minute with a leading zero. 04
[m] Displays elapsed time in minutes (to be used when the time value exceeds 60 minutes). 62196479
s Displays the second without a leading zero. 31
ss with a leading zero. 31
[s] Displays elapsed time in seconds (to be used when the time value exceeds 60 seconds). 3731788771
AM/PM Converts to 12-hour time. Displays either AM/am/A/a or PM/pm/P/p depending on the time of day. PM
am/pm pm
A/P P
a/p p

Come in Colors Everywhere

Number Formatting can be used color sections of a code. A common example is using the color red for negative numbers. Color code must be placed inside square brackets (i.e. [color]), and entered at the beginning of a section. Here are some available colors,

  • [Black]
  • [Blue]
  • [Cyan]
  • [Green]
  • [Magenta]
  • [Red]
  • [White]
  • [Yellow]
Raw Value Format Code Formatted Value
1234.567 [Green]#,##0.00_);[Red](#,##0.00);[Blue]0.00);[Magenta]@ 1,234.57
-1234.567 (1,234.57)
0 0.00
This is a text This is a text

Conditions

Although Excel has conditional formatting menu, basic conditions can be applied through code. Condition should be placed inside square brackets (i.e. [condition]) just like colors. Conditions are similar to the conditions in some functions (i.e. SUMIF). First add a logical operator, and then a value. For example, “[>=1000000]” means “if value of cell is greater than or equal to 1,000,000 apply the following format”. Conditions should come before the actual code, again, just like with colors. If you want to a color as well, the color code should come first.

Another important thing to note here is, that section structure changes from Positive, Negative, Zero, Text to First Condition, Second Condition (if exists), if previous conditions are not applied. There should be at least two sections for conditions.

If you enter only one condition code and then save the format, Excel will automatically add the second section with «;General». This means that if the condition is not met, General format will be used.

Источник

Sometimes we want to fill 1,2,3,4,5… into each cell in a column, for implement this we can enter 1 in the first cell and then drag fill handle down to fill the following cells. But if there are some texts exist with number in cell for example Student001-1-A, we drag down the fill handle, the other cells are only copied the original value, number 001 will not be increased automatically. So, we need to find a simple way that to make number with texts continuous in cells. This article will provide you a simple solution to create increment number with text in cells easily.

Precondition:

See screenshot below. For student, we use 001,002,003…to identify them, we can type text like ‘Student001-1-A’ one by one manually, but if there are 100 or 1000 students, it will spend a long time to finish this task. So we need simple ways to solve this issue.

Create Increment Number with Texts 1

Table of Contents

  • Method 1: Create Increment Number with Texts by ‘&’ in Excel
  • Method 2: Create Increment Number Within Texts by Formula in Excel
    • Related Functions

As we can see the texts are combined as ‘Student00x-1-A’, so we can separate them firstly, then create increment number in one column, and at last combine all texts again. Please see below steps for details.

Step 1: Separate texts in column A to two parts.

Create Increment Number with Texts 2

(Make sure -1-A is saved in Text format, otherwise error will be displayed)

Step 2: Select the range covers column C and column D, drag fill handle down to create increment numbers in column C, and text in column D is copied and pasted.

Create Increment Number with Texts 3

Step 3: In cell E2 enter the formula =C2&D2.

Create Increment Number with Texts 4

Step 4: Drag down the fill handle in column E till reaching the last data.

Create Increment Number with Texts 5

Step 5: Just copy column E, in column A, right click select Paste Special->Paste Values (the first choice).

Create Increment Number with Texts 6

Then increment numbers within texts are created properly.

Method 2: Create Increment Number Within Texts by Formula in Excel


We can see that in texts ‘Student001-1-A’, except ‘001’ part, other parts are unchanged. So we can extract this part, and then create increment number based on it, and then use formula to combine all parts together.

Step 1: Separate texts ‘Student001-1-A’ to three parts. In column C save ‘Student’, column D save ‘1’, column E save ‘-1-A’.

Create Increment Number with Texts 7

Step 2: On D2, drag fill handle down to create increment numbers.

Create Increment Number with Texts 8

Step 3: In F2 enter the formula =$C$2&TEXT(D2,”000″)&$E$2.

Create Increment Number with Texts 9

Step 4: Click Enter to check result.

Create Increment Number with Texts 10

Step 5: Drag the fill handle down to fill cells till the last data.

Create Increment Number with Texts 11

Then you can refer to above method step#5 to copy and paste data properly.


  • Excel Text function
    The Excel TEXT function converts a numeric value into text string with a specified format. The TEXT function is a build-in function in Microsoft Excel and it is categorized as a Text Function. The syntax of the TEXT function is as below: = TEXT (value, Format code)…

In all versions of Excel, you can use a simple formula, with the & operator, to combine values from different cells. If you want the numbers formatted a certain way, use the TEXT function to set that up.

Video: Combine Text and Numbers

First, this video shows a simple formula to combine text and numbers in Excel. Then, see how to use the Excel TEXT function, to format the numbers in the formula.

You can type the formatting information inside the TEXT function. Or, put the formatting string in a different cell, and refer to that cell in the TEXT function.

To follow along, get the sample file on my Contextures site – How to Combine Cells

TEXTJOIN – Excel 365

If you’re using Excel 365, there’s a new TEXTJOIN function. It makes it easy to combine values from multiple cells.

This short video shows a couple of TEXTJOIN examples. First, see a simple formula to combine weekday names. Next, use the TEXT function inside TEXTJOIN, create formatted dates. There are written steps, and more examples, on my Contextures website.

Simple Formula

Even if you don’t have the new TEXTJOIN function, it’s easy combine values from multiple cells, using a simple formula. Just use the & (ampersand) operator, to join values together.

In this example:

  • There’s text in cell A2, with a space character at the end.
  • There’s an unformatted number in cell B2.

This formula, in cell C2, combines the text and number:

=A2 & B2

Or, if the text does not have a space character at the end, add one in the formula

=A2 & " " & B2

combinetextnumbers02

Format Numbers with TEXT Function

To join text with formatted numbers, use the TEXT function in the formula.

In this example:

  • There’s text in cell A2, with a space character at the end.
  • There’s a formatted date in cell B2.

This formula, in cell C2, combines the text and date, with formatting:

=A2 & TEXT(B2,"d-mmm")

combinetextnumbers03

Number Format Information

Instead of typing the number format inside the TEXT function, you could type those formats in another column, or on a different worksheet.

Then, in the TEXT function, refer to the cell with the required format.

For example, I’ve made a formatting list with named cells. Now, I can use those names in the TEXT function.

  • FmtDMY    d-mmm-yyyy
  • FmtCurr    $#,##0
  • FmtFrac    # ?/?

combinetextnumbers04

In this example, the formula in C2 uses the d-mmm-yyyy format, from the cell named FmtDMY:

=A2 & TEXT(B2,FmtDMY)

The other named formats are used in cells C5 and C8.

Currency – cell C5

=A5 & TEXT(B5,FmtCurr)

Fraction – cell C8

=A8 & TEXT(B8,FmtFrac)

combinetextnumbers05

Get the Workbook

To see more examples of combining text and numbers, and to get the sample workbook, go to the Combine Cells page on my Contextures site.

The zipped file is in xlsx format, and does not contain any macros.

________________________________

Combine Text and Formatted Numbers in Excel

Combine Text and Formatted Numbers in Excel

Combine Text and Formatted Numbers in Excel

________________________________

Helper Columns

The fastest way to approach problems like this is often to use helper columns to break the problem down. To do math on the numerical portions, I extracted the numbers.

enter image description here

You can get the locations of everything from the position of the R. In column B, I extracted the L number. B1:

=MID(A1,2,FIND("R",A1)-3)*1

MID extracts the characters starting with the second, for a length of the R position minus 3 (i.e., minus the L, -, and R). That is extracted as a string, so multiplying by 1 turns it into a number.

The R number is in column C. C1:

 =MID(A1,FIND("R",A1)+1,LEN(A1))*1

In this case, MID starts at the position after the R, and takes the rest of the string. The number of characters is specified as the entire length of the A1 value, but Excel runs out of characters when it comes to the end of the string.

An alternate way to get the R number is the approach used in Rajesh S’s answer:

=REPLACE(A1,1,FIND("R",A1),"")*1

This replaces all of the characters to the left of the number, from the first through the R, with nothing. Again, the *1 converts the result to a numerical value.

The result in A8 is generated by building the new string using & to concatenate the pieces, plugging in the helper column sums:

="L" & SUM(B1:B6) & "-R" & SUM(C1:C6)

You can hide the helper columns or stick them out of the way if you don’t want them visible.

Without helper columns

Once you’ve figured out how to do it with helper columns, you can often eliminate the helper columns by using the formula in an array-style calculation. SUMPRODUCT lets you do that with a regular formula; it calculates the result for each value in the range, then sums them up. The sum of the L values can be done directly with:

=SUMPRODUCT(--(MID(A1:A6,2,FIND("R",A1:A6)-3)))

This is the same formula used for the helper column, but the single cell reference is replaced with the data range. This also illustrates another method for converting the text result to a number; Instead of *1, it uses a double negative to treat the result as a number while leaving its sign unchanged.

Similarly, for the R number, I’ll use the alternate formula because it’s a little shorter:

=SUMPRODUCT(--(REPLACE(A1:A6,1,FIND("R",A1:A6),"")))

Those formulas give you the sums without needing the helper columns. You can build the final result in a single cell by using these sums instead of the SUM(B1:B6) and SUM(C1:C6) that used the helper column results:

="L" & SUMPRODUCT(--(MID(A1:A6,2,FIND("R",A1:A6)-3))) & "-R" & SUMPRODUCT(--(REPLACE(A1:A6,1,FIND("R",A1:A6),"")))

Dynamic answer on another sheet

To have an automatically updated result replicated on another sheet, just put, in that display cell, a reference to the original result. You include the sheet name in the cell reference, connected by an exclamation mark. To refer to the result in cell A8 of Sheet1, the cell reference would be =Sheet1!A8.

A fast way to create the cell reference is to type = in the display cell, then before hitting Enter, go to the first sheet and click on the result cell. Excel will fill in the cell reference for you.

Like this post? Please share to your friends:
  • Excel adding not working
  • Excel adding drop downs
  • Excel adding columns to a table
  • Excel addin in vba
  • Excel add to table vba