Text value of a cell in excel

The TEXT function lets you change the way a number appears by applying formatting to it with format codes. It’s useful in situations where you want to display numbers in a more readable format, or you want to combine numbers with text or symbols.

Note: The TEXT function will convert numbers to text, which may make it difficult to reference in later calculations. It’s best to keep your original value in one cell, then use the TEXT function in another cell. Then, if you need to build other formulas, always reference the original value and not the TEXT function result.

Syntax

TEXT(value, format_text)

The TEXT function syntax has the following arguments:

Argument Name

Description

value

A numeric value that you want to be converted into text.

format_text

A text string that defines the formatting that you want to be applied to the supplied value.

Overview

In its simplest form, the TEXT function says:

  • =TEXT(Value you want to format, «Format code you want to apply»)

Here are some popular examples, which you can copy directly into Excel to experiment with on your own. Notice the format codes within quotation marks.

Formula

Description

=TEXT(1234.567,«$#,##0.00»)

Currency with a thousands separator and 2 decimals, like $1,234.57. Note that Excel rounds the value to 2 decimal places.

=TEXT(TODAY(),«MM/DD/YY»)

Today’s date in MM/DD/YY format, like 03/14/12

=TEXT(TODAY(),«DDDD»)

Today’s day of the week, like Monday

=TEXT(NOW(),«H:MM AM/PM»)

Current time, like 1:29 PM

=TEXT(0.285,«0.0%»)

Percentage, like 28.5%

=TEXT(4.34 ,«# ?/?»)

Fraction, like 4 1/3

=TRIM(TEXT(0.34,«# ?/?»))

Fraction, like 1/3. Note this uses the TRIM function to remove the leading space with a decimal value.

=TEXT(12200000,«0.00E+00»)

Scientific notation, like 1.22E+07

=TEXT(1234567898,«[<=9999999]###-####;(###) ###-####»)

Special (Phone number), like (123) 456-7898

=TEXT(1234,«0000000»)

Add leading zeros (0), like 0001234

=TEXT(123456,«##0° 00′ 00»»)

Custom — Latitude/Longitude

Note: Although you can use the TEXT function to change formatting, it’s not the only way. You can change the format without a formula by pressing CTRL+1 (or Image of the MAC Command button icon+1 on the Mac), then pick the format you want from the Format Cells > Number dialog.

Download our examples

You can download an example workbook with all of the TEXT function examples you’ll find in this article, plus some extras. You can follow along, or create your own TEXT function format codes.

Download Excel TEXT function examples

Other format codes that are available

You can use the Format Cells dialog to find the other available format codes:

  1. Press Ctrl+1 (Image of the MAC Command button icon+1 on the Mac) to bring up the Format Cells dialog.

  2. Select the format you want from the Number tab.

  3. Select the Custom option,

  4. The format code you want is now shown in the Type box. In this case, select everything from the Type box except the semicolon (;) and @ symbol. In the example below, we selected and copied just mm/dd/yy.

  5. Press Ctrl+C to copy the format code, then press Cancel to dismiss the Format Cells dialog.

  6. Now, all you need to do is press Ctrl+V to paste the format code into your TEXT formula, like: =TEXT(B2,»mm/dd/yy«). Make sure that you paste the format code within quotes («format code»), otherwise Excel will throw an error message.

Example of using the Format > Cells > Number > Custom dialog to have Excel create format strings for you.

Format codes by category

Following are some examples of how you can apply different number formats to your values by using the Format Cells dialog, then use the Custom option to copy those format codes to your TEXT function.

Why does Excel delete my leading 0’s?

Excel is trained to look for numbers being entered in cells, not numbers that look like text, like part numbers or SKU’s. To retain leading zeros, format the input range as Text before you paste or enter values. Select the column, or range where you’ll be putting the values, then use CTRL+1 to bring up the Format > Cells dialog and on the Number tab select Text. Now Excel will keep your leading 0’s.

If you’ve already entered data and Excel has removed your leading 0’s, you can use the TEXT function to add them back. You can reference the top cell with the values and use =TEXT(value,»00000″), where the number of 0’s in the formula represents the total number of characters you want, then copy and paste to the rest of your range.

Examples of using TEXT to format leading zeros.  =TEXT(A2,"00000")

If for some reason you need to convert text values back to numbers you can multiply by 1, like =D4*1, or use the double-unary operator (—), like =—D4.

Excel separates thousands by commas if the format contains a comma (,) that is enclosed by number signs (#) or by zeros. For example, if the format string is «#,###», Excel displays the number 12200000 as 12,200,000.

A comma that follows a digit placeholder scales the number by 1,000. For example, if the format string is «#,###.0,», Excel displays the number 12200000 as 12,200.0.

Examples of the TEXT function using the Thousands separator

Notes: 

  • The thousands separator is dependent on your regional settings. In the US it’s a comma, but in other locales it might be a period (.).

  • The thousands separator is available for the number, currency and accounting formats.

Following are examples of standard number (thousands separator and decimals only), currency and accounting formats. Currency format allows you to insert the currency symbol of your choice and aligns it next to your value, while accounting format will align the currency symbol to the left of the cell and the value to the right. Note the difference between the currency and accounting format codes below, where accounting uses an asterisk (*) to create separation between the symbol and the value.

Examples of the TEXT function with Number, Currency and Accounting formats

To find the format code for a currency symbol, first press Ctrl+1 (or Image of the MAC Command button icon+1 on the Mac), select the format you want, then choose a symbol from the Symbol drop-down:

Currency Symbol selection from the Format Cells dialog

Then click Custom on the left from the Category section, and copy the format code, including the currency symbol.

TEXT function - Custom currency with symbol

Note: The TEXT function does not support color formatting, so if you copy a number format code from the Format Cells dialog that includes a color, like this: $#,##0.00_);[Red]($#,##0.00), the TEXT function will accept the format code, but it won’t display the color.

You can alter the way a date displays by using a mix of «M» for month, «D» for days, and «Y» for years.

Month, Day and Year format codes

Format codes in the TEXT function aren’t case sensitive, so you can use either «M» or «m», «D» or «d», «Y» or «y».

You can alter the way time displays by using a mix of «H» for hours, «M» for minutes, or «S» for seconds, and «AM/PM» for a 12-hour clock.

Time formats for hours, minutes and seconds

If you leave out the «AM/PM» or «A/P», then time will display based on a 24-hour clock.

Format codes in the TEXT function aren’t case sensitive, so you can use either «H» or «h», «M» or «m», «S» or «s», «AM/PM» or «am/pm».

You can alter the way decimal values display with percentage (%) formats.

Format codes for Percent

You can alter the way decimal values display with fraction (?/?) formats.

Format codes for Fractions

Scientific notation is a way of displaying numbers in terms of a decimal between 1 and 10, multiplied by a power of 10. It is often used to shorten the way that large numbers display.

Format codes for Scientific notation

Excel provides 4 special formats:

  • Zip Code — «00000»

  • Zip Code + 4 — «00000-0000»

  • Phone Number — «[<=9999999]###-####;(###) ###-####»

  • Social Security Number — «000-00-0000»

Special formats for the TEXT function

Special formats will be different depending on locale, but if there aren’t any special formats for your locale, or if these don’t meet your needs then you can create your own through the Format Cells > Custom dialog.

Common scenario

The TEXT function is rarely used by itself, and is most often used in conjunction with something else. Let’s say you want to combine text and a number value, like “Report Printed on: 03/14/12”, or “Weekly Revenue: $66,348.72”. You could type that into Excel manually, but that defeats the purpose of having Excel do it for you. Unfortunately, when you combine text and formatted numbers, like dates, times, currency, etc., Excel doesn’t know how you want to display them, so it drops the number formatting. This is where the TEXT function is invaluable, because it allows you to force Excel to format the values the way you want by using a format code, like «MM/DD/YY» for date format.

In the following example, you’ll see what happens if you try to join text and a number without using the TEXT function. In this case, we’re using the ampersand (&) to concatenate a text string, a space (» «), and a value with =A2&» «&B2.

Example of joining text without the TEXT function

As you can see, Excel removed the formatting from the date in cell B2. In the next example, you’ll see how the TEXT function lets you apply the format you want.

Example of joining text with the TEXT function

Our updated formula is:

  • Cell C2:=A2&» «&TEXT(B2,»mm/dd/yy») — Date format

Frequently Asked Questions

Yes, you can use the UPPER, LOWER and PROPER functions. For example, =UPPER(«hello») would return «HELLO».

Yes, but it takes a few steps. First, select the cell or cells where you want this to happen and use Ctrl+1 to bring up the Format > Cells dialog, then Alignment > Text control > check the Wrap Text option. Next, adjust your completed TEXT function to include the ASCII function CHAR(10) where you want the line break. You might need to adjust your column width depending on how the final result aligns.

Example of using TEXT with CHAR(10) to insert a line break. ="Today is: "&CHAR(10))&TEXT(TODAY(),"MM/DD/YY")

In this case, we used: =»Today is: «&CHAR(10)&TEXT(TODAY(),»mm/dd/yy»)

This is called Scientific Notation, and Excel will automatically convert numbers longer than 12 digits if a cell(s) is formatted as General, and 15 digits if a cell(s) is formatted as a Number. If you need to enter long numeric strings, but don’t want them converted, then format the cells in question as Text before you input or paste your values into Excel.

See Also

Create or delete a custom number format

Convert numbers stored as text to numbers

All Excel functions (by category)

Our Comment Policy.

We welcome your comments and questions about this lesson. We don’t welcome spam. Our readers get a lot of value out of the comments and answers on our lessons and spam hurts that experience. Our spam filter is pretty good at stopping bots from posting spam, and our admins are quick to delete spam that does get through. We know that bots don’t read messages like this, but there are people out there who manually post spam. I repeat — we delete all spam, and if we see repeated posts from a given IP address, we’ll block the IP address. So don’t waste your time, or ours. One other point to note — if you post a link in your comment, it will automatically be deleted.

Add a comment to this lesson

.

Comments on this lesson

Bringing only selected data forward

I have a job costing calculator and i only want to bring text forward to a front sheet in the workbook to summarize the selections. For example: the calculator lists several items offered, I want to bring only the items selected to a front page for a summary of the items selected to that specific job. So if there are 100 items that could be chosen, and only 5 are selected, I want to have a table that shows those 5 items only. AND the items are text not numerical value.

SO the job costing page may have : Window Removal and a cell to populate a number [number of windows to be removed] if that cell has a value greater than 0 i want the text «window removal» brought to another table for summary…I have tried IF functions and am not getting desired result…please help. Thanks

.

Extract number

I would like to extract the number out of column G (Description of goods) into column H (serial numbers) can you assist with a formula

.

Useful tips

Thanks 5 minutes were really 5 minutes and managed to extract data i wanted. Good work.

.

Extracting Numbers From a String

I am trying to separate the numbers from a string of text that contains numbers. The following is a sample string:
C4-14-3-6-21
I’d like to get the numbers into individual cells (except for the C4 part of the string which never changes). 14 is the year and will always be two digits. 3 will eventually become 2 digits long and then 3 and finally 4. The 6 will probably never be more than 2 digits long and the 21 can go 5 or 6 digits long. So far, I was able to create the following formulas that isolated the year (14) and the 3 (next number to the right):
=0+MID(A1,4,FIND(«-«,A1,4)-4)
=0+MID(A1,7,FIND(«-«,A1,7)-7)
It seems to work for the 14 and 3 slots. I haven’t been successful extracting the 6 and 21 (after testing different number of digits). Can you help me get these formulas right to extract all of the numbers?

.

LEFT

In the last exemple «=RIGHT(A1,LEN(A1)-FIND(«.»,A1))» how to do it to get just the names instead of the numbers? Because if you use «=LEFT(A1,LEN(A1)-FIND(«.»,A1))» it give all sting.

Thanks

.

Extract Text from a Cell in Excel

Hi there,

I am trying to extract the set of numbers before the first «~»
My attempt using Formula=RIGHT(A1,LEN(A1)-FIND(«.»,A1)) returned a «0»

3932730~20~17074~S2930248~1~14~S~A-07-02-08~~1
517398~1~17074~S2930248~1~27~S~A-04-07-02
345219~1~17074~S2930248~1~5~S~A-03-01-04
239068~1~17074~S2930248~1~33~S~A-06-05-03
3935400~1~17074~S2930248~1~17~S~A-07-02-03
345219~20~17074~S2930248~1~5~S~A-03-01-04~~1
1742393~1~17074~S2930248~1~36~S~B-16-04-07

Can you please help with this? Kind regards,

Brian

.

Brian,

Brian,

Try using =Left(A1,FIND(«~»,A1)-1)

.

Use Find/Replace

I Know I am very late, but just use replace option with text to find as «~*» and replace with null «»

.

Hello I’m trying to separate

Hello I’m trying to separate specific parts of text from a set of addresses. For example:
800 E DIMOND BLVD STE 127
800 E DIMOND BLVD SUITE 127
320 W 5TH AVE
3048 MOUNTAIN VIEW DR BLDG 119
2120 US HIGHWAY 92 W

On this text I would like to separate the last two parts which are «ste» and «127» to a separate column, the thing is that some addresses don’t have «ste» instead they have «suite» » building», etc. Is there any way that would be possible?

.

Moe,

Moe,

I’m sure it is possible, but I’m not the expert that could tell you how to do it. I’m sorry. I posted my original question to extract a single number from a string of numbers separated by hyphens. Try posting your question as a new string. Good luck.

Regards,

Lubo

.

leaving instead of extracting last octet

I am trying to get only the last octet of an ip address that is in a cell. Instead of using text to columns is there a way to leave only the last octet?

.

no result from Mid command

Col A B C D E F G
Invoice Status Cd State Acct Company Code Invoice Number Invoice Date Contract Number ARN
CO TX S580 65336 1/13/2014 NREC_TX_185584_CTL =MID(F2,9,6)

Using the MID formula listed under the ARN field, I am getting no result whatsoever. Excel 2007 file type .xlxs. What I want is in the ARN column G the number 185584.

.

minor update

dang, it didn’t save my spaces betweent the column numbers. Col F has the Contract Number.

.

extract lot number

6006 — Silicone Tip Capsule Polisher 23gX7mm bend Lot#: 04146016 Loc.: 5
5003AF — Irrigating Cystotome 25gX16mm (5/8″) formed Lot#: 12146050 Loc.: 84-86
Retrobulbar Needle 23gX1 1/2″ (Atkinson Point) Lot#: 01156001

3 different rows, what I need: «Lot#: xxxxxxxx» or just the 5th digit in the lot #, in these rows it would be «6» (if you look at my attachment, Column L & M work for must but since the location [Loc] has a different number of digits, notice cell M3 cuts off some of the Lot #.

TYIA

.

Extracting three different parts of a cell

I need to extract three different parts in the below string of text. I need to extract flavors loved to return «Fruits, Fruits & Cream, Dessert» (it can include quotations in the text. Flavors hated «Tobacco, discovery», then Nicotine level «Low (6mg)

{«flavors_loved»:[«Fruits»,»Fruits & Cream»,»Dessert»],»flavors_hated»:»Tobacco»,»discovery»:»Expand Range»,»nicotine_level»:[«Low (6mg)»]}

.

How to extract numbers within square brackets

Hi,
I have a spreadsheet contains several thousand of records.
These records (column A) contains text strings at and numbers within a square brackets at many various lengths.
What I would like to achieve is how extract just the numbers within the square brackets of column A into a new column. Examples of records as follow;

«Bangalore Street» Beams Road [4069]
«Clifton Hill» O/B Ipswich Road FS Beaudesert Rd [10386]
«HOMEBASE» [3368]

Could someone assist me.
Thanks in advance

.

This is a bit messy, but it

This is a bit messy, but it works.

=mid(A1,find(«[«,A1)+1,find(«]»,A1)-find(«[«,A1)-1)

.

Thanks so much Cionn.

Thanks so much Cionn.
I’ve performed search & replace the open square bracket replaced with symbol then did find formular similar to yours and it works the same way as yours. Thanks for responding to my call for help. Cheers

.

Sorting problem

Below is a sample cell value within my spreadsheet (it’s voting history- general election, primary election). I want to be able to sort using this column. The sorting would be, for example, all persons with a GE14 and a GE12 and a PE11. And various combinations like that. How could I accomplish that?

GE14GE13PE13GE12GE08GE04GE01GE00GE97

.

Sorting problem

Below is a sample cell value within my spreadsheet (it’s voting history- general election, primary election). I want to be able to sort using this column. The sorting would be, for example, all persons with a GE14 and a GE12 and a PE11. And various combinations like that. How could I accomplish that?

GE14GE13PE13GE12GE08GE04GE01GE00GE97

.

More information please …

Hi Matt

Can you be more specific about what you want to achieve? You say you want to sort, but I don’t have enough information to decide where, say, someone with GE14, G13 and PE11 might be ranked compared to someone with GE14, GE13 but not PE11.

Also, can you provide a couple of additional samples, and decode the formula? For example, it looks like this is a person who voted in the General Election in 2014, 2013, 2012, 2008, 2004, 2001, 2000 and 1997, and in a Primary Election in 2013. What I can’t tell is whether these are the only years in which elections were held, or if there was, say, a GE every year, but this person didn’t vote in every one of them.

Thanks.

David

.

Hi David. Thanks for the

Hi David. Thanks for the help. The value in this column is that person’s individual voting history. I’m not interested in ranking them. I only want to parcel out those people who, say, voted in GE14, GE12, and GE10. If all three of those values don’t appear in this cell, then (for present sorting purposes) I’m not interested in that person. So I’m wondering what formula I would use. Some sort of if(and(search…As you’ve probably guessed, I’m a novice exceller. Tks for any guidance you can provide.

.

Finding numbers

Hi,

I am a stock markets professional and have an excel file with hundreds of records in the following sample formats:

NIFTY JUN 8500 CE
BANKNIFTY JUL 18800 PE
STAR AUG 1300 CE
INDUSINDBK JAN 900 CE
JPASSOCIAT AUG 10 PE

What I want to do is just extract the numbers out of these cells and use it in a separate formula. I would be grateful if somebody could help me with this.

Regards,

Vikas.

.

Extracting $ amount from a cell

Hello —

Here is an example where all I want to extract is the $4,532.50. I have several like this but not one is the same. I am just looking in that cell for the actual dollar amount and that is it. Is there a formula for that? And it can be in anywhere from $x.xx to $xxx,xxx.xx. Thanks for your assistance.

Archive Hans Wegner Table (DS) AX 2364 $4,532.50 080315 #202061,86 3520

.

Pulling text from the end of a string to a new column

Pulling text from the end of a string to a new column, with different length prefixes. I really need some help here :)

I need to get the size indicator of the end of the Sku into the next column
The M, XL, L and S
How can I do this because they are different lengths?

.

This formula is almost what I need to do.

Hello,

This formula is what I need, but I need to see another step. In my case I do have » : » and I need to grab everything as the last » : «

Example:

MY Part number: Susp IP:Torsion bars:911:1-SAW911F19

I need to grab the last part of the number just this part 1-SAW911F19

This formula almost gets me what I need =RIGHT(A1,LEN(A1)-FIND(«:»,A1)) but it get me everything after the first » : «

Thank you for your help.

VH

.

Very percise and satisfying

Very percise and satisfying answer. Thank you so much, you are very helpful.

.

Same Problem here

Did you solve your problem? Mine is very similar.
rumo-log-RUMO3
bmfbovespa-BVMF3
vale-VALE5
itausa-ITSA4
banco-do-brasil-BBAS3
itau-unibanco-ITUB4
guarapes-GUAR4
braskem-BRKM5
estacio-participacoes-ESTC3
br-malls-par-BRML3
brasilagro-AGRO3
cosan-ltd-CZLT33
unicasa-UCAS3
grendene-GRND3
alupar-ALUP11
fii-cshg-jhsf-HGJH11
fii-bc-fund-BRCR11
portobello-PTBL3
mills-MILS3
cielo-CIEL3

I’m trying to get only the last caps words. This formula =RIGHT(B3;LEN(B3)-FIND(«-«;B3)) works great with data with only 2 words, but the rest bring me stuff that I dont need

.

Found it

This worked for me! =TRIM(RIGHT(SUBSTITUTE(E2,»-«,REPT(» «,100)),100))

Hope it works for you too!

.

pulling text of different lengths

I am trying to pull the model of a product (text and numerical) from the beginning of each cell into another column for total product model analysis. Some models have one word, some have 3-4 words plus a number.

example:
Big River P 700c, 555, 0
Spy Hill 7.3 P 27.5, L3, 0
Glass Creek Pro Carbon Q, 29, 0

I would like to extract:
Big River
Spy Hill 7.3
Glass Creek Pro Carbon

See attached for actual data

.

Extracting

ip address 10.10.10.10
ip address 10.10.10.11
ip address 10.10.10.12
.
.
How can we extract only: 10.10.10.10 and 10.10.10.11 and so on?

.

string with unequal characters with 2 delimiters

My data is of different lengths, and the only constant is that the part I want to remove is always the last 11 characters. Alternatively, the data I want to retrieve is up to but not including the second underscore: Here is a sample:
R5510BU010_MAIN_926030_PDF
R5510BU010_MAIN_926028_PDF
R5510BU021_ALL_925732_PDF
R5510BU021_REGULAR_926026_PDF
R5510BU010_MAIN_925736_PDF
R5510BU021_REGULAR_925734_PDF
R5510BU010_MAIN_925738_PDF
R5510BU021_ALL_926024_PDF
R5510BU021_REGULAR_925468_PDF
R5510BU010_MAIN_925470_PDF
R5510BU010_MAIN_925472_PDF

What I am trying to do is retrieve everything up to but not including the second underscore. I can’t use left because the fields are unequal lengths, and when I use right, it returns the stuff I’m trying to remove.

Is there a better way?

Thanks

.

Addendum to above question

Sorry, I forgot to add:

I tried this formula: =LEFT(G2,LEN(G2)-FIND(«_»,G2)) and it returned:

R5510BU010_MAIN
R5510BU010_MAIN
R5510BU021_ALL
R5510BU021_REGULAR
R5510BU010_MAIN
R5510BU021_REGULAR
R5510BU010_MAIN
R5510BU021_ALL
R5510BU021_REGULAR
R5510BU010_MAIN
R5510BU010_MAIN

This looks great, but when I copied to down to the rest of the cells I got this:

R09801_ZJDE0002_926264_PDF returned R09801_ZJDE0002_926
R09801_ZJDE0002_925803_PDF returned R09801_ZJDE0002_925
R09801_ZJDE0002_925801_PDF returned R09801_ZJDE0002_925
R09801_ZJDE0002_925805_PDF returned R09801_ZJDE0002_925
R09801_ZJDE0002_925807_PDF returned R09801_ZJDE0002_925
R09801_ZJDE0002_925809_PDF returned R09801_ZJDE0002_925
R09801_ZJDE0002_925811_PDF returned R09801_ZJDE0002_925
R09801_ZJDE0002_926290_PDF returned R09801_ZJDE0002_926

Why did it seem to understand in the first selection but not the second?

Thanks

.

Ease of access to specific issues in 5 minute lessons

Thank you very much for putting up 5 minute lessons. They work better than excel help menu and the explanations are far more comprehensive & useful. I use 5 minute lesson as my excel help menu.

.

Extract text from a cell

I have a situation where I need to extract some or all of the DATA in a cell.
I am an options trader and at the end of the day i would like to know the underlying stock symbol for the option which will help easily filter and sort the trades.

stock symbols normally range between 1 and 4 letters

GDX
GDX 160708P28
GDX 160708P28
BBRY 160916C9
SLV 160805C19.5
SLV

=LEFT(B11,FIND(» «,B11))
This works fine for the option chain, but if its just the stock»SLV» it returns an error

The values im looking for are listed below
GDX
GDX
GDX
BBRY
SLV
SLV

Thanks for your help

.

Extracting Multiple info from a string of text

The below contains info found in a cell separated by commas. I’d to separate each of the info grouped by commas and put into different cells. At the moment I can only extract only the first set «PKL70080P» using =LEFT(A65,FIND(«,»,A65)-1). The rest I’m not sure how to do that.

PKL70080P,»Tbitha 318* x .02 LB OPT»,TPLin,5/12/2011,19,81,96,82,91,81,85,98,94,95,92,98,80,N/A,»»

Thanks!

.

Extracting ‘Sub ID’

I am trying to extract a 32 alphanumeric subscription ID out of the Forecast Comments column. Forecast comments are essentially notes exported from our CRM system. The majority of the sales reps have «Sub ID[space]» prior to the IS, so I tried =RIGHT(J2,LEN(J2)-FIND(«Sub ID «,J2)) but I got an error. Also I don’t want all the notes that are in the cell AFTER the Sub ID.

.

Extracting ‘Sub ID’

I am trying to extract a 32 alphanumeric subscription ID out of the Forecast Comments column. Forecast comments are essentially notes exported from our CRM system. The majority of the sales reps have «Sub ID[space]» prior to the IS, so I tried =RIGHT(J2,LEN(J2)-FIND(«Sub ID «,J2)) but I got an error. Also I don’t want all the notes that are in the cell AFTER the Sub ID.

.

Extracting ‘Sub ID’

I am trying to extract a 32 alphanumeric subscription ID out of the Forecast Comments column. Forecast comments are essentially notes exported from our CRM system. The majority of the sales reps have «Sub ID[space]» prior to the IS, so I tried =RIGHT(J2,LEN(J2)-FIND(«Sub ID «,J2)) but I got an error. Also I don’t want all the notes that are in the cell AFTER the Sub ID.

.

i was lost in hope and faith

i was lost in hope and faith when i was unable to get into my account that i save all my document and file ,but thanks to cyberhelp company who help me get into my account and get everything back for me with no stress just give them some info and everything is done within 5hours really amazing to work with them ,thats why im so proud to recommend they to people to use them and they will never disappoint you ,,contact them on ( cyberhelp027 @ …gmail .com ) and you thanks me later
or text them on +160 64413481 or What Sapp +1 7863616429

.

Extracting Data from one cell to copy in another

Hi,
I am trying to find a way of extracting only part of a cells contents if it contains certain characteristics. So in cell C2 I have a long bank narrative which may contain a policy number. They number always begin with the same 2 letters for example AB followed by 7 numbers.

How can I get excel to check C2 and if it contains anything which begins AB followed by 7 numbers it will copy the policy number to cell G2? The policy number could be anywhere in the text so it needs to be able to go through the whole cell content.

Thanks for any help you can give

.

Extracting Data from one cell to copy in another

Hi,
I am trying to find a way of extracting only part of a cells contents if it contains certain characteristics. So in cell C2 I have a long bank narrative which may contain a policy number. They number always begin with the same 2 letters for example AB followed by 7 numbers.

How can I get excel to check C2 and if it contains anything which begins AB followed by 7 numbers it will copy the policy number to cell G2? The policy number could be anywhere in the text so it needs to be able to go through the whole cell content.

Thanks for any help you can give

.

.

.

.

Date yes Add (Subtract) Days to a Date Concatenate Dates Convert Date to Number Convert Date to Text Month Name to Number Create Date Range from Dates Day Number of Year Month Name from Date First Day of Month Add (Subtract) Weeks to a Date If Functions with Dates Max Date Number of Days Between Dates Number of Days in a Month Number of Weeks Between Dates Number of Years Between Dates Split Date & Time into Separate Cells Countdown Remaining Days Insert Dates Random Date Generator Using Dynamic Ranges — Year to Date Values Add (Subtract) Years to a Date Date Formula Examples Extract Day from Date Get Day Name from Date Count Days Left in Month / Year Count Workdays Left in Month / Year Get Last Day of Month Last Business Day of Month / Year Number of Work / Business Days in Month Weekday Abbreviations Auto Populate Dates Number of Months Between Dates Quarter from a Date Years of Service Change Date Format Compare Dates Time yes Add (Subtract) Hours to Time Add (Subtract) Minutes to Time Add (Subtract) Seconds to Time Add Up time (Total Time) Time Differences Change Time Format Convert Minutes to Hours Convert Time to Decimal Convert Time to Hours Convert Time to Minutes Convert Time to Seconds Military Time Round Time to Nearest 15 Minutes Overtime Calculator Number of Hours Between Times Convert Seconds to Minutes, Hours, or Time Count Hours Worked Time Differences Time Format — Show Minutes Seconds Text yes Add Commas to Cells Get First Word from Text Capitalize First Letter Clean & Format Phone #s Remove Extra Trailing / Leading Spaces Add Spaces to Cell Assign Number Value to Text Combine Cells with Comma Combine First and Last Names Convert Text String to Date Convert Text to Number Extract Text From Cell Get Last Word Remove Unwated Characters Extract Text Before or After Character How to Split Text String by Space, Comma, & More Remove Special Characters Remove First Characters from Left Substitute Multiple Values Switch First & Last Names w/ Commas Remove Specific Text from a Cell Extract Text Between Characters (Ex. Parenthesis) Add Leading Zeros to a Number Remove Line Breaks from Text Remove all Numbers from Text Reverse Text Remove Non-Numeric Characters Remove Last Character(s) From Right Separate First and Last Names Separate Text & Numbers Round yes Round Formulas Round Price to Nearest Dollar or Cent Round to Nearest 10, 100, or 1000 Round to Nearest 5 or .5 Round Percentages Round to Significant Figures Count yes Count Blank and Non-blank Cells Count Cells Between Two Numbers Count Cells not Equal to Count if Cells are in Range Count Times Word Appears in Cell Count Words in Cell Count Specific Characters in Column Count Total Number of Characters in Column Count Cells that Equal one of two Results Count Cells that do not Contain Count Cells that Contain Specific Text Count Unique Values in Range Countif — Multiple Criteria Count Total Number of Cells in Range Count Cells with Any Text Count Total Cells in a Table Lookup yes Two Dimensional VLOOKUP VLOOKUP Simple Example Vlookup — Multiple Matches Case Sensitive Lookup Case Sensitive VLOOKUP Sum if — VLOOKUP Case Sensitive Lookup Case Sensitive VLOOKUP Find Duplicates w/ VLOOKUP or MATCH INDEX MATCH MATCH Lookup — Return Cell Address (Not Value) Lookup Last Value in Column or Row Reverse VLOOKUP (Right to Left) Risk Score Bucket with VLOOKUP Sum with a VLOOKUP Function VLOOKUP & INDIRECT VLOOKUP Concatenate VLOOKUP Contains (Partial Match) 17 Reasons Why Your XLOOKUP is Not Working Double (Nested) XLOOKUP — Dynamic Columns IFERROR (& IFNA) XLOOKUP Lookup Min / Max Value Nested VLOOKUP Top 11 Alternatives to VLOOKUP (Updated 2022!) VLOOKUP – Dynamic Column Reference VLOOKUP – Fix #N/A Error VLOOKUP – Multiple Sheets at Once VLOOKUP & HLOOKUP Combined VLOOKUP & MATCH Combined VLOOKUP Between Worksheets or Spreadsheets VLOOKUP Duplicate Values VLOOKUP Letter Grades VLOOKUP Return Multiple Columns VLOOKUP Returns 0? Return Blank Instead VLOOKUP w/o #N/A Error XLOOKUP Multiple Sheets at Once XLOOKUP Between Worksheets or Spreadsheets XLOOKUP by Date XLOOKUP Duplicate Values XLOOKUP Multiple Criteria XLOOKUP Return Multiple Columns XLOOKUP Returns 0? Return Blank Instead XLOOKUP Text XLOOKUP with IF XLOOKUP With If Statement Misc. yes Sort Multiple Columns Use Cell Value in Formula Percentage Change Between Numbers Percentage Breakdown Rank Values Add Spaces to Cell CAGR Formula Average Time Decimal Part of Number Integer Part of a Number Compare Items in a List Dealing with NA() Errors Get Worksheet Name Wildcard Characters Hyperlink to Current Folder Compound Interest Formula Percentage Increase Create Random Groups Sort with the Small and Large Functions Non-volatile Function Alternatives Decrease a Number by a Percentage Calculate Percent Variance Profit Margin Calculator Convert Column Number to Letter Get Full Address of Named Range Insert File Name Insert Path Latitute / Longitude Functions Replace Negative Values Reverse List Range Convert State Name to Abbreviation Create Dynamic Hyperlinks Custom Sort List with Formula Data Validation — Custom Formulas Dynamic Sheet Reference (INDIRECT) Reference Cell in Another Sheet or Workbook Get Cell Value by Address Get Worksheet Name Increment Cell Reference List Sheet Names List Skipped Numbers in Sequence Return Address of Max Value in Range Search by Keywords Select Every Other (or Every nth) Row Basics yes Cell Reference Basics — A1, R1C1, 3d, etc. Add Up (Sum) Entire Column or Row Into to Dynamic Array Formulas Conversions yes Convert Time Zones Convert Celsius to Fahrenheit Convert Pounds to Kilograms Convert Time to Unix Time Convert Feet to Meters Convert Centimeters to Inches Convert Kilometers to Miles Convert Inches to Feet Convert Date to Julian Format Convert Column Letter to Number Tests yes Test if a Range Contains any Text Test if any Cell in Range is Number Test if a Cell Contains a Specific Value Test if Cell Contains Any Number Test if Cell Contains Specific Number Test if Cell is Number or Text If yes Percentile If Subtotal If Sumproduct If Large If and Small If Median If Concatentate If Max If Rank If TEXTJOIN If Sum yes Sum if — Begins With / Ends With Sum if — Month or Year to Date Sum if — By Year Sum if — Blank / Non-Blank Sum if — Horizontal Sum Count / Sum If — Cell Color INDIRECT Sum Sum If — Across Multiple Sheets Sum If — By Month Sum If — Cells Not Equal To Sum If — Not Blank Sum if — Between Values Sum If — Week Number Sum Text Sum if — By Category or Group Sum if — Cell Contains Specific Text (Wildcards) Sum if — Date Rnage Sum if — Dates Equal Sum if — Day of Week Sum if — Greater Than Sum if — Less Than Average yes Average Non-Zero Values Average If — Not Blank Average — Ignore 0 Average — Ignore Errors Math yes Multiplication Table Cube Roots nth Roots Square Numbers Square Roots Calculations yes Calculate a Ratio Calculate Age KILLLLLLL Calculate Loan Payments GPA Formula Calculate VAT Tax How to Grade Formulas Find yes Find a Number in a Column / Workbook Find Most Frequent Numbers Find Smallest n Values Find nth Occurance of Character in Text Find and Extract Number from String Find Earliest or Latest Date Based on Criteria Find First Cell with Any Value Find Last Row Find Last Row with Data Find Missing Values Find Largest n Values Most Frequent Number Conditional Formatting yes Conditional Format — Dates & Times Conditional Format — Highlight Blank Cells New Functions XLOOKUP Replaces VLOOKUP, HLOOKUP, and INDEX / MATCH Logical yes AND Checks whether all conditions are met. TRUE/FALSE IF If condition is met, do something, if not, do something else. IFERROR If result is an error then do something else. NOT Changes TRUE to FALSE and FALSE to TRUE. OR Checks whether any conditions are met. TRUE/FALSE XOR Checks whether one and only one condition is met. TRUE/FALSE Lookup & Reference yes FALSE The logical value: FALSE. TRUE The logical value: TRUE. ADDRESS Returns a cell address as text. AREAS Returns the number of areas in a reference. CHOOSE Chooses a value from a list based on it’s position number. COLUMN Returns the column number of a cell reference. COLUMNS Returns the number of columns in an array. HLOOKUP Lookup a value in the first row and return a value. HYPERLINK Creates a clickable link. INDEX Returns a value based on it’s column and row numbers. INDIRECT Creates a cell reference from text. LOOKUP Looks up values either horizontally or vertically. MATCH Searches for a value in a list and returns its position. OFFSET Creates a reference offset from a starting point. ROW Returns the row number of a cell reference. ROWS Returns the number of rows in an array. TRANSPOSE Flips the oriention of a range of cells. VLOOKUP Lookup a value in the first column and return a value. Date & Time yes DATE Returns a date from year, month, and day. DATEDIF Number of days, months or years between two dates. DATEVALUE Converts a date stored as text into a valid date DAY Returns the day as a number (1-31). DAYS Returns the number of days between two dates. DAYS360 Returns days between 2 dates in a 360 day year. EDATE Returns a date, n months away from a start date. EOMONTH Returns the last day of the month, n months away date. HOUR Returns the hour as a number (0-23). MINUTE Returns the minute as a number (0-59). MONTH Returns the month as a number (1-12). NETWORKDAYS Number of working days between 2 dates. NETWORKDAYS.INTL Working days between 2 dates, custom weekends. NOW Returns the current date and time. SECOND Returns the second as a number (0-59) TIME Returns the time from a hour, minute, and second. TIMEVALUE Converts a time stored as text into a valid time. TODAY Returns the current date. WEEKDAY Returns the day of the week as a number (1-7). WEEKNUM Returns the week number in a year (1-52). WORKDAY The date n working days from a date. WORKDAY.INTL The date n working days from a date, custom weekends. YEAR Returns the year. YEARFRAC Returns the fraction of a year between 2 dates. Engineering yes CONVERT Convert number from one unit to another. Financial yes FV Calculates the future value. PV Calculates the present value. NPER Calculates the total number of payment periods. PMT Calculates the payment amount. RATE Calculates the interest Rate. NPV Calculates the net present value. IRR The internal rate of return for a set of periodic CFs. XIRR The internal rate of return for a set of non-periodic CFs. PRICE Calculates the price of a bond. YIELD Calculates the bond yield. INTRATE The interest rate of a fully invested security. Information yes CELL Returns information about a cell. ERROR.TYPE Returns a value representing the cell error. ISBLANK Test if cell is blank. TRUE/FALSE ISERR Test if cell value is an error, ignores #N/A. TRUE/FALSE ISERROR Test if cell value is an error. TRUE/FALSE ISEVEN Test if cell value is even. TRUE/FALSE ISFORMULA Test if cell is a formula. TRUE/FALSE ISLOGICAL Test if cell is logical (TRUE or FALSE). TRUE/FALSE ISNA Test if cell value is #N/A. TRUE/FALSE ISNONTEXT Test if cell is not text (blank cells are not text). TRUE/FALSE ISNUMBER Test if cell is a number. TRUE/FALSE ISODD Test if cell value is odd. TRUE/FALSE ISREF Test if cell value is a reference. TRUE/FALSE ISTEXT Test if cell is text. TRUE/FALSE N Converts a value to a number. NA Returns the error: #N/A. TYPE Returns the type of value in a cell. Math yes ABS Calculates the absolute value of a number. AGGREGATE Define and perform calculations for a database or a list. CEILING Rounds a number up, to the nearest specified multiple. COS Returns the cosine of an angle. DEGREES Converts radians to degrees. DSUM Sums database records that meet certain criteria. EVEN Rounds to the nearest even integer. EXP Calculates the exponential value for a given number. FACT Returns the factorial. FLOOR Rounds a number down, to the nearest specified multiple. GCD Returns the greatest common divisor. INT Rounds a number down to the nearest integer. LCM Returns the least common multiple. LN Returns the natural logarithm of a number. LOG Returns the logarithm of a number to a specified base. LOG10 Returns the base-10 logarithm of a number. MOD Returns the remainder after dividing. MROUND Rounds a number to a specified multiple. ODD Rounds to the nearest odd integer. PI The value of PI. POWER Calculates a number raised to a power. PRODUCT Multiplies an array of numbers. QUOTIENT Returns the integer result of division. RADIANS Converts an angle into radians. RAND Calculates a random number between 0 and 1. RANDBETWEEN Calculates a random number between two numbers. ROUND Rounds a number to a specified number of digits. ROUNDDOWN Rounds a number down (towards zero). ROUNDUP Rounds a number up (away from zero). SIGN Returns the sign of a number. SIN Returns the sine of an angle. SQRT Calculates the square root of a number. SUBTOTAL Returns a summary statistic for a series of data. SUM Adds numbers together. SUMIF Sums numbers that meet a criteria. SUMIFS Sums numbers that meet multiple criteria. SUMPRODUCT Multiplies arrays of numbers and sums the resultant array. TAN Returns the tangent of an angle. TRUNC Truncates a number to a specific number of digits. Stats yes AVERAGE Averages numbers. AVERAGEA Averages numbers. Includes text & FALSE =0, TRUE =1. AVERAGEIF Averages numbers that meet a criteria. AVERAGEIFS Averages numbers that meet multiple criteria. CORREL Calculates the correlation of two series. COUNT Counts cells that contain a number. COUNTA Count cells that are non-blank. COUNTBLANK Counts cells that are blank. COUNTIF Counts cells that meet a criteria. COUNTIFS Counts cells that meet multiple criteria. FORECAST Predict future y-values from linear trend line. FREQUENCY Counts values that fall within specified ranges. GROWTH Calculates Y values based on exponential growth. INTERCEPT Calculates the Y intercept for a best-fit line. LARGE Returns the kth largest value. LINEST Returns statistics about a trendline. MAX Returns the largest number. MEDIAN Returns the median number. MIN Returns the smallest number. MODE Returns the most common number. PERCENTILE Returns the kth percentile. PERCENTILE.INC Returns the kth percentile. Where k is inclusive. PERCENTILE.EXC Returns the kth percentile. Where k is exclusive. QUARTILE Returns the specified quartile value. QUARTILE.INC Returns the specified quartile value. Inclusive. QUARTILE.EXC Returns the specified quartile value. Exclusive. RANK Rank of a number within a series. RANK.AVG Rank of a number within a series. Averages. RANK.EQ Rank of a number within a series. Top Rank. SLOPE Calculates the slope from linear regression. SMALL Returns the kth smallest value. STDEV Calculates the standard deviation. STDEV.P Calculates the SD of an entire population. STDEV.S Calculates the SD of a sample. STDEVP Calculates the SD of an entire population TREND Calculates Y values based on a trendline. Text yes CHAR Returns a character specified by a code. CLEAN Removes all non-printable characters. CODE Returns the numeric code for a character. CONCATENATE Combines text together. DOLLAR Converts a number to text in currency format. EXACT Test if cells are exactly equal. Case-sensitive. TRUE/FALSE FIND Locates position of text within a cell.Case-sensitive. LEFT Truncates text a number of characters from the left. LEN Counts number of characters in text. LOWER Converts text to lower case. MID Extracts text from the middle of a cell. PROPER Converts text to proper case. REPLACE Replaces text based on it’s location. REPT Repeats text a number of times. RIGHT Truncates text a number of characters from the right. SEARCH Locates position of text within a cell.Not Case-sensitive. SUBSTITUTE Finds and replaces text. Case-sensitive. TEXT Converts a value into text with a specific number format. TRIM Removes all extra spaces from text. UPPER Converts text to upper case. VALUE Converts a number stored as text into a number.

The TEXT excel function converts a number to a text string based on the format specified by the user. This format is supplied as an argument to the TEXT function. Since the resulting outputs are text representations of numbers, they cannot be used as is in formulas. Therefore, it is recommended to retain the original numbers and create a separate row or column for the converted numbers.

For example, the formula “=TEXT(“10/2/2022″,”mmmm dd, yyyy”)” returns February 10, 2022. Exclude the beginning and ending double quotation marks while entering this formula in Excel.

The purpose of using the TEXT function in Excel is to display a number in the desired format. Since this function also helps combine numbers with other text strings, it tends to make the output more legible. The TEXT function is particularly used when the number formats of different datasets need to be made identical.

Estimated reading time: 21 minutes

Table of contents
  • What is Text Function in Excel?
    • Syntax of the TEXT Function of Excel
    • How to Use the TEXT Function in Excel?
      • Example #1–Prefix the Text Strings to the Newly Formatted Date Values
      • Example #2–Join the Newly Formatted Time and Date Values
      • Example #3–Extract a Mobile Number from its Scientific Notation
      • Example #4–Prefix a Text String to the Initially Formatted Monetary Value
    • Date Formats of Excel
    • Frequently Asked Questions
    • TEXT Function in Excel Video
    • Recommended Articles

Syntax of the TEXT Function of Excel

The syntax of the TEXT function of Excel is shown in the following image:

TEXT Formula

The TEXT function of Excel accepts the following arguments:

  • Value: This is the number to be converted to a text string. Apart from a number, a date, time or cell reference can also be supplied to the TEXT excel function. The cell reference can contain either a number or an output of another function which can be a number or date.
  • Format_text: This is the format to be applied to the “value” argument. It is also called the format code. It is entered within double quotation marks in the TEXT formula of Excel. For instance, “0.00,” “dd/mm/yyyy,” “hh:mm:ss,” and so on are format codes.

Both the stated arguments are mandatory.

Note 1: The format code “0.00” displays a number with two decimal places. In the format code “dd/mm/yyyy,” “dd,” “mm,” and “yyyy” are the notations for days (in two digits), months (in two digits), and years (in four digits) respectively.

Likewise, “hh,” “mm,” and “ss” are the notations for hours (in two digits), minutes (in two digits), and seconds (in two digits) respectively.

For the meaning of the different date formats, refer to the heading “date formats of Excel” given after example #4 of this article.

Note 2: The TEXT function is categorized as a Text/String function of Excel. The TEXT function is available in all versions of Excel.

How to Use the TEXT Function in Excel?

Let us consider some examples to understand the working of the TEXT function in Excel.

Example #1–Prefix the Text Strings to the Newly Formatted Date Values

The following table shows the names of five children along with the dates they were born on. The dates are currently in the format m/d/yyyy. Consider the two columns and six rows of the table as columns A and B and rows 1 to 6 of Excel.

We want to perform the following tasks:

  • Join the name and date of birth of row 2 by using the ampersand operator. There should not be any space between the joined values.
  • Convert each date to the format “dd mmm, yyyy.” Prefix the child’s name and the string “was born on” to each date.
  • Show the output when the date of row 2 is in the format “d mmm, yyyy.” Let the prefixes of the preceding point stay as it is.
  • Show the date formats “dd mmm, yyyy” (in cell C2) and “d mmm, yyyy” (in cell C6) in a single column.

Explain the outputs obtained in the second and fourth bullet points. Use the TEXT function of Excel.

Name of Kid Date of Birth
John 12/8/2015
Patricia 1/12/2014
Ram 3/11/2016
Anita 11/11/2017
Davis 5/6/2014

The steps to perform the given tasks by using the TEXT function of Excel are listed as follows:

Step 1: Enter the following formula in cell C2. Exclude the beginning and ending double quotation marks while entering the given formula.

“=A2&“”&B2”

This formula (shown in the image of step 2) joins the values of cells A2 and B2 without any spaces in-between.

Note: The ampersand operator (&) helps join the values of two or more cells. It is called the concatenation operator and is used as an alternative to the CONCATENATE function of Excel. There is no limit on the number of cell values that the ampersand can join.

Step 2: Press the “Enter” key. The output appears in cell C2, as shown in the following image.

Notice that Excel has joined the values of cells A2 and B2 without any spaces in-between. However, the output is not in a readable format. The reason is that the date (12/8/2015) has been converted to a sequential number. The number 42346 represents the date December 8, 2015.

Note: A date is stored in Excel as a sequential or a serial number. This is because a serial number makes it easy to perform calculations. To view the serial number of a date, refer to the “note” preceding step 3 of example #2.

TEXT Function Example 3-1

Step 3: To apply the format “dd mmm, yyyy” and insert the stated prefixes, enter the following formula in cell C2.

“=A2&” was born on “&TEXT(B2,”dd mmm, yyyy”)”

Press the “Enter” key. Then, drag the formula of cell C2 till cell C6 by using the fill handle. The outputs are displayed in the following image.

Example 3-2

Explanation of the outputs: In column C of the preceding image, the child’s name (in column A) and the text string (was born on) have been prefixed to each date of column B. Since the date is in a suitable format, the output is readable now.

The joined values (outputs) of column C are in the form of statements that are easier to understand than the single values of columns A and B.

Notice that, to insert spaces as the separators in the output, we have inserted spaces at the relevant places in the formula of step 1. Moreover, a comma has also been inserted after the notation of months (mmm). This comma can be seen in each date of the output (in column C).

Step 4: To see the output when the date format is “d mmm, yyyy” and the prefixes are in place, enter the following formula in cell C2.

=A2&” was born on “&TEXT(B2,”d mmm, yyyy”)

Press the “Enter” key. The output appears in cell C2, as shown in the following image.

Notice that the leading zero before the date 8 Dec, 2015 (in cell C2) has disappeared. This zero was there in cell C2 of the preceding image. It has disappeared because, in the current format code, the number of days is represented by a single “d.”

A single “d” omits the leading zeros when the number of days is in a single digit.

Example 3-3

Step 5: The outputs obtained after applying different date formats in the same column (column C) are shown in the following image.

Example 3-4

Explanation of the outputs: Notice that in the preceding image, the date of cell C2 is in the format “d mmm, yyyy” while that of cell C6 is in the format “dd mmm, yyyy.” The only difference between these two date formats is in the number of days. The leading zero is absent in cell C2 and present in cell C6.

Hence, with the TEXT function of Excel, one can have different date formats in different cells of the same column. Remember that a format code changes only the appearance of a value; it does not change the value itself. One can create a format code depending on the requirement.

Example #2–Join the Newly Formatted Time and Date Values

The following table shows the times and dates in two separate columns. Consider these columns as columns A and B of Excel. We want to perform the following tasks:

  • Join (concatenate) each time value with the respective date. Use the ampersand operator (&) and ensure that there is no space between the two values.
  • Show how to copy the formats “h:mm:ss am/pm” and “m/d/yyyy” from the “format cells” window. Convert each time to the former and date to the latter format.
  • Join the converted time and date values with the ampersand operator (&). Ensure that there is a space between the two values.
  • Show the output when the date format is not enclosed within double quotation marks.

Explain the outputs obtained in the first and third bullet points. Use the TEXT function of Excel for the given tasks.

Time Date
7:00:00 AM 6/19/2018
7:15:00 AM 6/19/2018
7:30:00 AM 6/19/2018
7:45:00 AM 6/19/2018
8:00:00 AM 6/19/2018
8:15:00 AM 6/19/2018
8:30:00 AM 6/19/2018
8:45:00 AM 6/19/2018

The steps to perform the given tasks by using the TEXT function of Excel are listed as follows:

Step 1: Enter the following formula (without the beginning and ending double quotation marks) in cell C2.

“=A2&“”&B2”

This formula is shown in the image of step 2. It joins the values of cells A2 and B2 without a space in-between.

Step 2: Press the “Enter” key. Then, drag the formula of cell C2 till cell C9 by using the fill handle. The fill handle is displayed at the bottom-right side of cell C2.

The outputs are shown in the following image.

TEXT Function Example 1-1

Explanation of the outputs: In column C, the number 43270 (at the end) is the same throughout the range C2:C9. This is the serial number for the date June 19, 2018. The entire decimal number preceding this serial number is the time. So, the decimal number 0.2916667 (in cell C2) represents the time 7:00:00 am.

The outputs obtained in column C of the preceding image are not readable. The reason is that Excel has converted the times (of column A) to decimal numbers and dates (of column B) to sequential numbers. Moreover, joining the decimals with sequential numbers has made the outputs more complicated.

To be able to read the output, it needs to be converted to the relevant format codes. This conversion is shown further in this example.

Note: Excel stores dates as sequential (or serial) numbers and times as decimal numbers. Excel considers a time value as a part of a day. To view the number representing the date, perform the following actions:

  • Select any cell of the range B2:B9.
  • Press the keys “Ctrl+1” together. The “format cellsFormatting cells is an important technique to master because it makes any data presentable, crisp, and in the user’s preferred format. The formatting of the cell depends upon the nature of the data present.read more” window opens.
  • Select “general” under “category” in the “number” tab.

The serial number can be seen under “sample.” Click “cancel” to close the “format cells” window or “Ok” to change the date to a serial number.

Likewise, the decimal number representing the time can also be seen by selecting any cell of the range A2:A9 and following actions “b” and “c” listed above.

Step 3: To convert the time and date values to a readable format, let us first copy the format codes from the “format cells” window. So, select cell C2 and press the keys “Ctrl+1” together.

The “format cells” window opens, as shown in the following image. From the “number” tab, select “custom” under “category. Excel provides a list of formats under “type.”

TEXT Function Example 1-2

Step 4: Scroll down the list of formats given under “type.” Copy the format “h:mm:ss am/pm.” To copy, just select the format code and press the keys “Ctrl+C.”

The format code is shown in the following image. Once the format has been copied, close the “format cells” window.

Step 5: Copy the format code “m/d/yyyy” for converting the date values. This format code is also available under “type,” as shown in the following image.

Close the “format cells” window after copying the mentioned format code.

Step 6: To apply the new formats to the time and date values and join the resulting values, enter the following formula in cell C2.

“=TEXT(A2,”h:MM:SS AM/PM”)&” “&TEXT(B2,”m/d/yyyy”)”

This formula is shown in the image of step 7. If the format codes have been copied in the preceding steps, they can be pasted at the relevant places in the formula by pressing the shortcut “Ctrl+V.”

According to this formula, the time and date values of cells A2 and B2 are formatted as per the codes “h:MM:SS AM/PM” and “m/d/yyyy” respectively. The formatted (or converted) values are then joined with the ampersand operator.

Notice that in the formula, a space has also been entered within a pair of double quotation marks (like &“ ”&). This space will be inserted in the output at exactly that place where it has been entered in the formula.

Step 7: Press the “Enter” key after entering the TEXT formula. Drag the formula of cell C2 till cell C9.

The outputs are shown in the following image.

TEXT Function Example 1-5

Explanation of the outputs: The time and date values of columns A and B have been converted to the relevant formats in column C. The time values display the hours (h) in a single digit, minutes (mm) in two digits, and seconds (ss) also in two digits. Since all the time values belong to the period before noon, they display “am” at the end.

Likewise, the dates display the months (m) in a single digit, days (d) in a single digit, and years (yyyy) in four digits.

Notice that there is a space between the two joined values in column C. Even though we copied the code “h:mm:ss am/pm” (in step 4) and pasted “h:MM:SS AM/PM” (in step 6), we obtained the correct outputs in column C (in step 7). This is because the format codes are not case-sensitive, implying that “mm” is treated the same as “MM.”

Step 8: To see what happens when the format code for date is entered without the double quotation marks, type the following formula in cell C9.

“=TEXT(A2,”h:MM:SS AM/PM”)&” “&TEXT(B2,m/d/YYYY)”

Press the “Enter” key. Excel returns the “#NAME?” error, as shown in the following image. Therefore, for the TEXT excel function to work, the format code should necessarily be enclosed within double quotation marks.

TEXT Function Example 1-6

There are two images titled “image 1” and “image 2.” The following information is given:

  • Image 1 shows a number having eleven 9s in cell B2. When 1 is added to this number, its digits increase to 12. Excel displays the resulting 12-digit number (in cell B3) in a scientific notation.
  • Image 2 shows the names of some people (in column A) and their random mobile numbers in a scientific notation (in column B). The formula bar shows the mobile number of person A. Each mobile number consists of twelve digits, which includes a 2-digit country code at the beginning.

Note that a scientific notationIn Excel, scientific notation is a specific style of writing numbers in scientific and exponential forms. Scientific notation compactly helps display values, allowing us to compare and use the same in calculations.read more (or scientific format) often displays very large or very small numbers in a contracted form. We want to perform the following tasks:

  • Display the entire 12-digit mobile number without any spaces in-between.
  • Separate the country code from the rest of the number with the help of a hyphen.

Use the TEXT function of Excel for the given tasks.

Image 1

TEXT Function Example 2

Image 2

TEXT Function Example 2-1

The steps to perform the given tasks by using the TEXT function of Excel are listed as follows:

Step 1: Enter the following formula in cell D2.

“=TEXT(B2,”############”)”

This formula is shown in the formula bar of the succeeding image. Notice that there are 12 hashes in the formula, which represent the 12 digits of a mobile number.

Step 2: Press the “Enter” key. The output appears in cell D2. To obtain the outputs for the entire column D, drag the formula of cell D2 to cell D7. Use the fill handle of cell D2 (displayed at the bottom-right corner) for dragging.

The outputs of column D are shown in the succeeding image.

Note: The output is displayed (in column D) only when one enters a mobile number as an input (in column B) which is converted automatically (or manually) to a scientific format of Excel. In case, a scientific format is typed manually in column B; it cannot be converted to a mobile number of column D.

TEXT Function Example 2-2

Step 3: To separate the country codes from the rest of the number by using a hyphen, enter the following formula in cell D2.

“=TEXT(B2,“##-##########”)”

Press the “Enter” key. Next, drag the formula of cell D2 till cell D7 with the help of the fill handle. The formula of cell D2 and the outputs are shown in the following image.

Notice that in the formula, the hyphen is placed exactly where it is required in the output. Since only the first two digits of each mobile number are to be separated, the hyphen is placed after two hashes of the formula.

TEXT Function Example 2-3

Example #4–Prefix a Text String to the Initially Formatted Monetary Value

There are two images titled “image 1” and “image 2.” The following information is given:

  • Image 1 shows the gross profit, expenses, and net profit of an organization. All these numbers are in dollars.
  • Image 2 shows how the net profit has been computed. To calculate the net profit, the expenses have been subtracted from the gross profit.

We want to perform the following tasks:

  • Show the output when the string “the net profit is” is prefixed to the amount of net profit. Use the ampersand operator for this purpose.
  • Prefix the string “the net profit is” to the amount of net profit by using the ampersand. Ensure that in the output, the amount of net profit displays the dollar sign ($) and the comma at the correct places (like $52,291). Use the TEXT function of Excel for this purpose.

Explain the output obtained at the end.

Image 1

Example 4

Image 2

Example 4-1

The steps to perform the given tasks are listed as follows:

Step 1: Enter the following formula in cell A13.

“=”The net profit is “&B11”

Exclude the beginning and ending double quotation marks of the formula while entering it in Excel. This formula is shown in the image of step 2.

The given formula prefixes the string “the net profit is” to the value of cell B11. The ampersand helps join the stated string to the amount of net profit (in cell B11).

Step 2: Press the “Enter” key. The output appears in cell A13, as shown in the following image.

Notice that the dollar sign and the comma of the net profit amount (shown in cell B11) have been omitted in the output. Though the string “the net profit is” has been correctly prefixed. The spaces have also been inserted at the right places in cell A13.

Example 4-3

Step 3: To retain the dollar sign and the comma of the amount, enter the following formula in cell A13.

“=”The net profit is ” &TEXT(B11,”$#,##0.00″)”

Press the “Enter” key. The formula and the output are shown in cell A13 of the following image.

Notice that by mistake, a space has been inserted before the ampersand in the formula. However, even then, the correct output has been obtained in cell A13.

Example 4-2

Explanation of the output: This time, the amount of net profit has been properly written (including the dollar sign and the comma) in cell A13. The reason is that the amount of net profit has been converted to the appropriate format in addition to being prefixed by a text string.

So, with the TEXT function of Excel, one can join a number with any string and, at the same time, retain the initial formatting of the number.

Date Formats of Excel

The different format codes for dates have been described as follows:

Frequently Asked Questions

1. Define the TEXT function in Excel with the help of an example.

The TEXT function in Excel helps convert a numerical value to a text string. The conversion is carried out according to the format specified by the user. Once converted, the numerical value becomes a text representation of a number.

The formula “=TEXT(“2/12/2021”,“dddd-mmmm-yyyy”)” converts the date 2/12/2021 to Thursday-December-2021. Ensure that the beginning and ending double quotation marks are excluded while entering this TEXT formula in Excel.

Note: For the working of the TEXT function of Excel, refer to the examples of this article.

2. Why is the TEXT function used in Excel?

The TEXT function is used in Excel for the following reasons:

• It helps convert a numerical value to a text string having a new format.
• It eases joining a numerical value with a text string.
• It helps retain the format of the existing numerical value after concatenation (joining).
• It makes the date or time values given in sequential or decimal numbers more readable and understandable for the users.
• It helps add the leading zeros to a number.
• It allows inserting specific characters (like +,-,(),<>,: etc.) in the output.

Note: The different characters that can be entered in the TEXT formula are the plus (+), minus (-), equal to (=), parentheses (), less than and greater than signs <>, colon (:), apostrophe (‘), curly braces {}, caret (^), forward slash (/), ampersand (&), space ( ), tilde (~), and an exclamation point (!).

The characters should be entered in the format code. These characters are displayed at exactly those places (in the output) where they have been entered in the format code.

3. How is the TEXT function used to add the leading zeros to a number in Excel?

The steps to add the leading zeros to a number are listed as follows:

a. Type “=TEXT” followed by the opening parenthesis.
b. Enter the number as the “value” argument.
c. Enter those many zeros in the format code as the number of digits required in the output.
d. Close the parenthesis and press the “Enter” key.

The leading zeros are added to the number entered in step “b.”

For instance, if the number 148 should appear as a 5-digit number, enter the formula “=TEXT(“148”,“00000”)” without the beginning and ending double quotation marks. It returns 00148.

TEXT Function in Excel Video

Recommended Articles

This has been a guide to the TEXT function of Excel. Here we discuss how to use the TEXT function in Excel along with step-by-step examples. You may also look at these useful functions of Excel–

  • Separate Text in ExcelThe methods used to separate text in Excel are as follows: 1) Text to Column (Delimited and Fixed Width) 2) Using Excel Formulasread more
  • Add Formula Text in ExcelText in Excel Formula allows us to add text values to using the CONCATENATE function or the ampersand (&) symbol.read more
  • INDIRECT in MS Excel
  • Trim FunctionThe Trim function in Excel does exactly what its name implies: it trims some part of any string. The function of this formula is to remove any space in a given string. It does not remove a single space between two words, but it does remove any other unwanted spaces.read more

Use the CELL function to return a wide range of information about a reference. The type of information  returned is given as info_type, which must be enclosed in double quotes («»). CELL can return a cell’s address, the filename and path for a workbook, and information about the formatting used in the cell. See below for a full list of info types and format codes.

CELL is a volatile function, and can cause performance issues in large or complex worksheets.

The CELL function takes two arguments: info_type and reference. Info_type is a text string that indicates the type of information requested. See the table below for a full list of info types. Reference is a cell reference. Reference is typically a single cell. If reference refers to more than one cell, CELL returns information about the first cell in reference. For certain kinds of information (like filename) the cell address used for reference is optional and can be omitted. However, if reference is not supplied, CELL will return the name of the current «active sheet» which may or may not be the sheet where the formula exists, and might even be in a different workbook. To avoid confusion, use A1 for reference. 

Note: the CELL function is a volatile function and may cause performance issues in large or complex worksheets.

Examples

For example, to get the column number for C10:

=CELL("col", C10) // returns 3

To get the address of A1 as text:

=CELL("address",A1) // returns "$A$1"

To get the full path and workbook name for the current worksheet:

=CELL("filename",A1) // path + filename

CELL can also return format code information. For example, if A1 contains the number 100 with the currency number format applied, the CELL function will return «C2»:

=CELL("format",A1) // returns "C2"

When requesting the info_type «format» or «parentheses», a set of empty parentheses «()» is appended to the format returned if the number format uses parentheses for all values or for positive values. For example, if A1 uses the custom number format (0), then:

=CELL("format",A1) // returns "F0()"

Info types

The following info_types can be used with the CELL function:

Info_type Description
address returns the address of the first cell in reference (as text).
col returns the column number of the first cell in reference.
color returns the value 1 if the first cell in reference is formatted using color for negative values; or zero if not.
contents returns the value of the upper-left cell in reference. Formulas are not returned. Instead, the result of the formula is returned.
filename returns the file name and full path as text. If the worksheet that contains reference has not yet been saved, an empty string is returned.
format returns a code that corresponds to the number format of the cell. See below for a list of number format codes. If the first cell in reference is formatted with color for values < 0, then «-» is appended to the code. If the cell is formatted with parentheses, returns «() — at the end of the code value.
parentheses returns 1 if the first cell in reference is formatted with parentheses and 0 if not.
prefix returns a text value that corresponds to the label prefix — of the cell:  a single quotation mark (‘) if the cell text is left-aligned, a double quotation mark («) if the cell text is right-aligned, a caret (^) if the cell text is centered text, a backslash () if the cell text is fill-aligned, and an empty string if the label prefix is anything else.
protect returns 1 if the first cell in reference is locked or 0 if not.
row returns the row number of the first cell in reference.
type returns a text value that corresponds to the type of data in the first cell in reference:  «b» for blank when the cell is empty, «l»  for label if the cell contains a text constant, and «v» for value if the cell contains anything else.
width returns the column width of the cell, rounded to the nearest integer. A unit of column width is equal to the width of one character in the default font size. Note: this value comes back as an array with two values {width,default} where width is the column width and default is a boolean value that indicates if the width is the default column width. 

Format codes

The table below shows the text codes returned by CELL when «format» is used for info_type.

Format code returned Format code meaning
G General
F0 0
,0 #,##0
F2 0
,2 #,##0.00
C0 $#,##0_);($#,##0)
C0- $#,##0_);[Red]($#,##0)
C2 $#,##0.00_);($#,##0.00)
C2- $#,##0.00_);[Red]($#,##0.00)
P0 0%
P2 0.00%
S2 0.00E+00
G # ?/? or # ??/??
D1 d-mmm-yy or dd-mmm-yy
D2 d-mmm or dd-mmm
D3 mmm-yy
D4 m/d/yy or m/d/yy h:mm or mm/dd/yy
D5 mm/dd
D6 h:mm:ss AM/PM
D7 h:mm AM/PM
D8 h:mm:ss

Notes

  • The CELL function is a volatile function and may cause performance issues in large or complex worksheets.
  • Reference is optional for some info types, but use an address like A1 to avoid unexpected behavior.

Value2 is almost always the best choice to read from or write to an Excel cell or a range… from VBA.

Range.Value2 '<------Best way

Each of the following can be used to read from a range:

v = [a1]
v = [a1].Value
v = [a1].Value2
v = [a1].Text 
v = [a1].Formula
v = [a1].FormulaR1C1

Each of the following can be used to write to a range:

[a1] = v
[a1].Value = v
[a1].Value2 = v
[a1].Formula = v
[a1].FormulaR1C1 = v

To read many values from a large range, or to write many values, it can be orders of magnitude faster to do the entire operation in one go instead of cell by cell:

arr = [a1:z999].Value2

If arr is a variable of type Variant, the above line actually creates an OLE SAFEARRAY structure of variants 26 columns wide and 999 rows tall and points the Variant arr at the SAFEARRAY structure in memory.

[a1].Resize(UBound(arr), UBound(arr, 2).Value2 = arr

The above line writes the entire array to the worksheet in one go no matter how big the array is (as long as it will fit in the worksheet).

The default property of the range object is the Value property. So if no property is specified for the range, the Value property is silently referenced by default.

However, Value2 is the quickest property to access range values and when reading it returns the true underlying cell value. It ignores Number Formats, Dates, Times, and Currency and returns numbers as the VBA Double data type, always. Since Value2 attempts to do less work, it executes slightly more quickly than does Value.

The Value property, on the other hand, checks if a cell value has a Number Format of Date or Time and will return a value of the VBA Date data type in these cases. If your VBA code will be working with the Date data type, it may make sense to retrieve them with the Value property. And writing a VBA Date data type to a cell will automatically format the cell with the corresponding date or time number format. And
writing a VBA Currency data type to a cell will automatically apply the currency Number Format to the appropriate cells.

Similarly, Value checks for cell currency formatting and then
returns values of the VBA Currency data type. This can lead to
loss of precision as the VBA Currency data type only recognizes
four decimal places (because the VBA Currency data type is really just a 64-bit Integer scaled by 10000) and so values are rounded to four places,
at most. And strangely, that precision is cut to just two decimal
places when using Value to write a VBA Currency variable to a worksheet range.

The read-only Text property always returns a VBA String data type. The value returned by Range.Text is a textual representation of what is displayed in each cell, inclusive of Number Formats, Dates, Times, Currency, and Error text. This is not an efficient way to get numerical values into VBA as implicit or explicit coercion is required. Text will return ####### when columns are too thin and it will slow down even more when some row heights are adjusted. Text is always VERY slow compared to Value and Value2. However, since Text retains the formatted appearance of cell values, Text may be useful, especially for populating userform controls with properly formatted text values.

Similarly, both Formula and FormulaR1C1 always return values as a VBA String data type. If the cell contains a formula then Formula returns its A1-style representation and FormulaR1C1 returns its R1C1 representation. If a cell has a hard value instead of a formula then both Formula and FormulaR1C1 ignore all formatting and return the true underlying cell value exactly like Value2 does… and then take a further step to convert that value to a string. Again, this is not an efficient way to get numerical values into VBA as implicit or explicit coercion is required. However, Formula and FormulaR1C1 must be used to read cell
formulas. And they should be used to write formulas to cells.

If cell A1 contains the numeric value of 100.25 with a currency number formatting
of $#,##0.00_);($#,##0.00) consider the following:

MsgBox [a1].Value                   'Displays:  100.25
MsgBox TypeName([a1].Value)         'Displays: Currency
 
MsgBox [a1].Value2                  'Displays:  100.25
MsgBox TypeName([a1].Value2)        'Displays: Double
 
MsgBox [a1].Text                    'Displays: $ 100.25
MsgBox TypeName([a1].Text)          'Displays: String
 
MsgBox [a1].Formula                 'Displays: 100.25
MsgBox TypeName([a1].Formula)       'Displays: String
 
MsgBox [a1].FormulaR1C1             'Displays: 100.25
MsgBox TypeName([a1].FormulaR1C1)   'Displays: String
  

Excel is a great tool which can be used for data entry, as a database, and to analyze data and create dashboards and reports.

While most of the in-built features and default settings are meant to be useful and save time for the users, sometimes, you may want to change things a little.

Converting your numbers into text is one such scenario.

In this tutorial, I will show you some easy ways to quickly convert numbers to text in Excel.

Why Convert Numbers to Text in Excel?

When working with numbers in Excel, it’s best to keep these as numbers only. But in some cases, having a number could actually be a problem.

Lets look at a couple of scenarios where having numbers creates issues for the users.

Keeping Leading Zeros

For example, if you enter 001 in a cell in Excel, you will notice that Excel automatically removes the leading zeros (as it thinks these are unnecessary).

While this is not an issue in most cases (as you wouldn’t leading zeros), in case you do need these then one of the solutions is to convert these numbers to text.

This way, you get exactly what you enter.

One common scenario where you might need this is when you’re working with large numbers – such as SSN or employee ids that have leading zeros.

Entering Large Numeric Values

Do you know that you can only enter a numeric value that is 15 digits long in Excel? If you enter a 16 digit long number, it will change the 16th digit to 0.

So if you are working with SSN, account numbers, or any other type of large numbers, there is a possibility that your input data is automatically being changed by Excel.

And what’s even worse is that you don’t get any prompt or error. It just changes the digits to 0 after the 15th digit.

Again, this is something that is taken care of if you convert the number to text.

Changing Numbers to Dates

This one erk a lot of people (including myself).

Try entering 01-01 in Excel and it will automatically change it to date (01 January of the current year).

So if you enter anything that is a valid date format in Excel, it would be converted to a date.

A lot of people reach out to me for this as they want to enter scores in Excel in this format, but end up getting frustrated when they see dates instead.

Again, changing the format of the cell from number to text will help keep the scores as is.

Now, let’s go ahead and have a look at some of the methods you can use to convert numbers to text in Excel.

Convert Numbers to Text in Excel

In this section, I will cover four different ways you can use to convert numbers to text in Excel.

Not all these methods are the same and some would be more suitable than others depending on your situation.

So let’s dive in!

Adding an Apostrophe

If you manually entering data in Excel and you don’t want your numbers to change the format automatically, here is a simple trick:

Add an apostrophe (‘) before the number

So if you want to enter 001, enter ‘001 (where there is an apostrophe before the number).

And don’t worry, the apostrophe is not visible in the cell. You will only see the number.

Number converted to text by adding an apostrophe

When you add an apostrophe before a number, it will change it to text and also add a small green triangle at the top left part of the cell (as shown in th image). It’s Exel way to letting you know that the cell has a number that has been converted to text.

When you add an apostrophe before a number, it tells Excel to consider whatever follows as text.

A quick way to visually confirm whether the cells are formatted as text or not is to see whether the numbers align to the left out to the right. When numbers are formatted as text, they align to the right by default (as they alight to the left)

Number with an without apostrophe
Adding an apostrophe changes cell alignment to left

Even if you add an apostrophe before a number in a cell in Excel, you can still use these as numbers in calculations

Similarly, if you want to enter 01-01, adding an apostrophe would make sure that it doesn’t get changed into a date.

Although this technique works in all cases, it is only useful if you’re manually entering a few numbers in Excel. If you enter a lot of data in a specific range of rows/columns, use the next method.

Converting Cell Format to Text

Another way to make sure that any numeric entry in Excel is considered a text value is by changing the format of the cell.

This way, you don’t have to worry about entering an apostrophe every time you manually enter the data.

You can go ahead entering the data just like you usually do, and Excel would make sure that your numbers are not changed.

Here is how to do this:

  1. Select the range or rows/column where you would be entering the data
  2. Click the Home tab
Click the Home tab
  1. In the Number group, click on the format drop down
Click on the format drop down
  1. Select Text from the options that show up
Select the Text formatting option

The above steps would change the default formatting of the cells from General to Text.

Now, if you enter any number or any text string in these cells, it would automatically be considered as a text string.

This means that Excel would not automatically change the text you enter (such as truncating the leading zeros or converting entered numbers into dates)

In this example, while I changed the cell formatting first before entering the data, you can also do this with cells that already have data in them.

But remember that if you already had entered numbers that were changed by Excel (such as removing leading zeros or changing text to dates), that won’t come back. You will have to make that data entry again.

Also, keep in mind that cell formatting can change in case you copy and paste some data to these cells. With regular copy-paste, it also copied the formatting from the copied cells. So it’s best to copy and paste values only.

Using the TEXT Function

Excel has an in-built TEXT function that is meant to convert a numeric value to a text value (where you have to specify the format of the text in which you want to get the final result).

This method is useful when you already have a set of numbers and you want to show them in a more readable format or if you want to add some text as suffix or prefix to these numbers.

Suppose you have a set of numbers as shown below, and you want to show all these numbers as five-digit values (which means to add leading zeros to numbers that are less than 5 digits).

Dataset with numbers of different digits

While Excel removes any leading zeros in numbers, you can use the below formula to get this:

=TEXT(A2,"00000")
TEXT formula result

In the above formula, I have used “00000” as the second argument, which tells the formula the format of the output I desire. In this example, 00000 would mean that I need all the numbers to be at least five-digit long.

You can do a lot more with the TEXT function – such as add currency symbol, add prefix or suffix to the numbers, or change the format to have comma or decimals.

Using this method can be useful when you already have the data in Excel and you want to format it in a specific way.

This can also be helpful in saving time when doing manual data entry, where you can quickly enter the data and then use the TEXT function to get it in the desired format.

Using Text to Columns

Another quick way to convert numbers to text in Excel is by using the Text to Columns wizard.

While the purpose of Text to Columns is to split the data into multiple columns, it has a setting that also allows us to quickly select a range of cells and convert all the numbers into text with a few clicks.

Suppose you have a data set is shown below, and you want to convert all the numbers in columns A into text.

Dataset with numbers of different digits

Below are the steps to do this:

  1. Select the numbers in Column A
  2. Click the Data tab
Click the Data tab
  1. Click on the Text to Columns icon in the ribbon. This will open the text to columns wizard this will open the text to column wizard
Click in the Text to Columns icon
  1. In Step 1 of 3, click the Next button
  2. In Step 2 of 3, click the Next button
  3. In Step 3 of 3, under the ‘Column data format’ options, select Text
Select Text option in the Text to Columns Wizard
  1. Click on Finish

The above steps would instantly convert all these numbers in Column A into text. You notice that the numbers would now be aligned to the right (indicating that the cell content is text).  

Numbers converted to text

There would also be a small green triangle at the top left part of the cell, which is a way Excel informs you that there are numbers that are stored as text.

So these are four easy ways that you can use to quickly convert numbers to text in Excel.

In case you only want this for a few cells where you would be manually entering the data, I suggest you use the apostrophe method. If you need to do data entry for more than a few cells, you can try changing the format of the cells from General to Text.

And in case you already have the numbers in Excel and you want to convert them to text, you can use the TEXT formula method or the Text to Columns method I covered in this tutorial.

I hope you found this tutorial useful.

Other Excel tutorials you may also like:

  • Convert Text to Numbers in Excel
  • How to Convert Serial Numbers to Dates in Excel
  • Convert Date to Text in Excel – Explained with Examples
  • How to Convert Formulas to Values in Excel
  • Convert Time to Decimal Number in Excel
  • How to Convert Inches to MM, CM, or Feet in Excel?
  • Convert Scientific Notation to Number or Text in Excel
  • Separate Text and Numbers in Excel

Microsoft Excel is a great tool, but sometimes the spreadsheet files we get to work with aren’t ideal. One example is a file with a data column, maybe a street address, that you’d really like to pull apart. In this tutorial, I’ll show how to extract text from a cell in Excel using some powerful, but simple text functions. (Includes practice workbook.)

What’s an Excel Substring?

Before we have Excel extract text from string, we need to define some things. Some programming languages have dedicated substring functions. Excel does something similar using Text functions. They have their own category.

Drop-down list of Excel text functions.

When we speak of a substring, we mean a part or subset of the Excel cell’s content. For example, if the cell contained 1001 Drake Ave., any of these items could be a substring:

  • 1001
  • Drake Ave.
  • 100
  • rake

A Common Problem

Many membership databases or mailing lists are set up with defined fields for First Name, Last Name, Street, City, State, and Zip. This format works fine if you’re creating a mailing label as the post office relies on zip code sorting. And sometimes you can luck out and parse first and last names using Excel’s Convert Text to Columns Wizard.

But what if you need to do door-to-door canvassing to check on neighbors or to inform people about an upcoming ballot measure?

If you open this type of list in Excel and sort it on the Street column, you get a numerically sorted list. As you can see in the example below, the Drake Ave records are not together.

Excel with single Street field sorted by number.

Excel with single Street field

Ideally, you want to sort the list so the Drake Ave. entries are together. There are several ways to do this in Excel, but one way is to create two columns from the Street column.

The first column reflects the street number substring, and the second the street name substring. You can then resort the list based on the street name and street number.

Visually Building the Nested Formula

For the first example, we’ll nest some Excel functions such as LEFT and FIND. As we progress, we’ll add several sets of parentheses. By nested, I mean we’ll use one function (FIND) as an argument for another function such as LEFT or RIGHT.

Let’s start with =FIND(" ",C2). In plain text, our function syntax is asking Excel to look in reference cell C2 for a blank space which is represented by the ” “. In the picture below, I added a starting position of “1“, but this is an optional parameter and Excel starts at 1 by default. Excel found the blank space in position 5 which shows in cell D2.

Using FIND to look for blank space.

To make the formula easier, I’ll remove the optional starting parameter of 1 since Excel starts there anyway.

Now, let’s add the LEFT function so that our formula reads =LEFT(C2,(FIND(" ",C2))). In this instance, we’re again using cell C2, but the LEFT function is going to grab the cell contents in C2 from position 1 to position 5 where the Excel FIND function found the blank space.

Extract text from excel cell with full street address.

However, there is a minor issue. While you can’t see it, there is a trailing space in D2. Using the LEN function we can see cell D2 has 5 characters. You may remember this handy function from our tutorial on how to check character count in Excel.

Using LEN function to show trailing space.

The solution is to subtract 1 or use the TRIM function which I referenced in how to separate names in Excel. For simplicity, I’ll use the -1. While the visual results are the same, you can see the character count dropped by 1.

Adding -1 to formula to adjust for trailing space.

  1. Import your data into Microsoft Excel or use the sample spreadsheet in the Resources section.
  2. In cell D1, type Nbr.
  3. In cell E1, type Street Name
  4. In cell D2, type the following Excel formula =LEFT(C2,(FIND(" ",C2)-1))
  5. Press Enter. The value 1001 should show in D2.

The next part involves copying this formula to the rest of the entries. However, we need to reference the correct street cell and not use C2 for the remaining rows.

  1. Click cell D2 to select the beginning of our range.
  2. Move your mouse to the lower right corner.

Clicking fill handle to copy formula.

Copy the Excel formula down the column
  1. Double-click the + cursor in the lower right. This will copy your formula down the column.

In column D, you should see the extracted street numbers.

We’ll now create a similar nested formula to capture the street address using the RIGHT function. This time, we will grab the contents to the right of the first space from the Street column.

  1. In cell E2, type the following formula =RIGHT(C2,LEN(C2)-FIND(" ",C2))
  2. Press Enter. E2 should show as Drake Ave.
  3. Click cell E2 to select the beginning of our range.
  4. Move your mouse to the lower right corner.
  5. Double-click the + cursor in the lower right. This will copy your formula down the column.

Columns D and E should contain the parsed contents from your original street address.

Your spreadsheet should look similar to the one below.

Excel with new number and street columns

Street Number and Names in new columns

Clean Up the Spreadsheet and Change Cell Format

The spreadsheet now has your split fields, but you should clean up the formulas. My suggestion would be to convert the LEFT and RIGHT formulas to their respective values. We did an earlier tutorial on how to copy formula values in Excel to values.

After you convert the Nbr column, you probably want to change the format type to a number.

  1. Click column D.
  2. Right-click and select Format cells...
  3. On the Format Cells dialog box, select Number.
  4. Set Decimal places to 0.
  5. Click OK.

Although our example extracted text from an Excel cell containing street information, you can use the same process to parse other entries. For example, Step 1 above is really parsing everything but the first word because it is searching for a blank space. You can alter the formula to find different values, such as a comma or an @ sign.

Excel Practice File

Hand-picked Excel Tutorials

Понравилась статья? Поделить с друзьями:
  • Text translator for excel
  • That nickname contains a banned word перевод
  • Text transform capitalize first word
  • That is are main word
  • Text to word translator