LikeOffice    Excel Consulting

Utility for Excel:

- Compare worksheets
- Database analysis
- Stock to your Excel
- Password recovery
- and many more...
 

 


This page presents how to work with Microsoft Excel 2007 features and its redesigned interface. You may also visit our Excel Question page.

   Text functions

   ASC function

   BAHTTEXT function

   CHAR function

   CLEAN function

   CODE function

   CONCATENATE function

   DOLLAR function

   EXACT function

   FIND, FINDB functions

   FIXED function

   JIS function

   LEFT, LEFTB functions

   LEN, LENB functions

   LOWER function

   MID, MIDB functions

   PHONETIC function

   PROPER function

   REPLACE, REPLACEB functions

   REPT function

   RIGHT, RIGHTB functions

   SEARCH, SEARCHB functions

   SUBSTITUTE function

   T function

   TEXT function

   TRIM function

   UPPER function

   VALUE function




Text functions

Click one of the links in the following list to see detailed help about the function.

Function

Description

ASC

Changes full-width (double-byte) English letters or katakana within a character string to half-width (single-byte) characters

BAHTTEXT

Converts a number to text, using the  (baht) currency format

CHAR

Returns the character specified by the code number

CLEAN

Removes all nonprintable characters from text

CODE

Returns a numeric code for the first character in a text string

CONCATENATE

Joins several text items into one text item

DOLLAR

Converts a number to text, using the $ (dollar) currency format

EXACT

Checks to see if two text values are identical

FIND, FINDB

Finds one text value within another (case-sensitive)

FIXED

Formats a number as text with a fixed number of decimals

JIS

Changes half-width (single-byte) English letters or katakana within a character string to full-width (double-byte) characters

LEFT, LEFTB

Returns the leftmost characters from a text value

LEN, LENB

Returns the number of characters in a text string

LOWER

Converts text to lowercase

MID, MIDB

Returns a specific number of characters from a text string starting at the position you specify

PHONETIC

Extracts the phonetic (furigana) characters from a text string

PROPER

Capitalizes the first letter in each word of a text value

REPLACE, REPLACEB

Replaces characters within text

REPT

Repeats text a given number of times

RIGHT, RIGHTB

Returns the rightmost characters from a text value

SEARCH, SEARCHB

Finds one text value within another (not case-sensitive)

SUBSTITUTE

Substitutes new text for old text in a text string

T

Converts its arguments to text

TEXT

Formats a number and converts it to text

TRIM

Removes spaces from text

UPPER

Converts text to uppercase

VALUE

Converts a text argument to a number


See Also




Excel > Function reference > Text and data

ASC function

For Double-byte character set (DBCS) languages, changes full-width (double-byte) characters to half-width (single-byte) characters.

Syntax

ASC(text)

Text   is the text or a reference to a cell that contains the text you want to change. If text does not contain any full-width letters, text is not changed.

Examples

=ASC("EXCEL")

equals "EXCEL"

=ASC("

")

equals " "


See Also




Excel > Function reference > Text and data

BAHTTEXT function

Excel 2007

Converts a number to Thai text and adds a suffix of "Baht."

In Excel for Windows, you can change the Baht format to a different style from the Control Panel by using Regional and Language Options in Windows Vista or in Microsoft Windows XP.

In Excel for the Macintosh, you can change the Baht number format to a different style by using Control Panel for Numbers.

Syntax

BAHTTEXT(number)

Number   is a number you want to convert to text, or a reference to a cell containing a number, or a formula that evaluates to a number.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

A


Data

1234

Formula

Description (Result)

=BAHTTEXT(A2)

Displays the number in text. (One thousand two hundred thirty four Baht in Thai text)


See Also




Excel > Function reference > Text and data

CHAR function

Excel 2007

Returns the character specified by a number. Use CHAR to translate code page numbers you might get from files on other types of computers into characters.

Operating environment

Character set

Macintosh

Macintosh character set

Windows

ANSI


Syntax

CHAR(number)

Number   is a number between 1 and 255 specifying which character you want. The character is from the character set used by your computer.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A

B

Formula

Description (Result)

=CHAR(65)

Displays the 65 character in the set (A)

=CHAR(33)

Displays the 33 character in the set (!)


See Also




Excel > Function reference > Text and data

CLEAN function

Excel 2007

Removes all nonprintable characters from text. Use CLEAN on text imported from other applications that contains characters that may not print with your operating system. For example, you can use CLEAN to remove some low-level computer code that is frequently at the beginning and end of data files and cannot be printed.

Important  The CLEAN function was designed to remove the first 32 nonprinting characters in the 7-bit ASCII code (values 0 through 31) from text. In the Unicode character set (Unicode: A character encoding standard developed by the Unicode Consortium. By using more than one byte to represent each character, Unicode enables almost all of the written languages in the world to be represented by using a single character set.), there are additional nonprinting characters (values 127, 129, 141, 143, 144, and 157). By itself, the CLEAN function does not remove these additional nonprinting characters. For an example of how to remove these additional nonprinting characters from text, see Remove spaces and nonprinting characters from text.

Syntax

CLEAN(text)

Text   is any worksheet information from which you want to remove nonprintable characters.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

A


Data

=CHAR(7)&"text"&CHAR(7)

Formula

Description (Result)

=CLEAN(A2)

Removes the nonprintable character, CHAR(7), from the string above (text)


See Also




Excel > Function reference > Text and data

CODE function

Excel 2007

Returns a numeric code for the first character in a text string. The returned code corresponds to the character set used by your computer.

Operating environment

Character set

Macintosh

Macintosh character set

Windows

ANSI


Syntax

CODE(text)

Text   is the text for which you want the code of the first character.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A

B

Formula

Description (Result)

=CODE("A")

Displays the numeric code for A (65)

=CODE("!")

Displays the numeric code for ! (33)


See Also




Excel > Function reference > Text and data

CONCATENATE function

Excel 2007

Tags  combine; combine text; connect; functions; join; mail merge; merge; text

What are tags?

This article describes the formula syntax and usage of the CONCATENATE function (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.) in Microsoft Office Excel.

Description

The CONCATENATE function joins up to 255 text strings into one text string. The joined items can be text, numbers, cell references, or a combination of those items. For example, if your worksheet contains a person's first name in cell A1 and the person's last name in cell B1, you can combine the two values in another cell by using the following formula:

=CONCATENATE(A1," ",B1)

The second argument in this example (" ") is a space character. You must specify any spaces or punctuation that you want to appear in the results as an argument that is enclosed in quotation marks.

Syntax

CONCATENATE(text1, [text2], ...)

The CONCATENATE function syntax has the following arguments (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.):

  • text1  Required. The first text item to be concatenated.
  • text2 ...  Optional. Additional text items, up to a maximum of 255 items. The items must be separated by commas.

 Note    You can also use the ampersand (&) calculation operator instead of the CONCATENATE function to join text items. For example, =A1 & B1 returns the same value as =CONCATENATE(A1, B1).

Example

The example may be easier to understand if you copy it to a blank worksheet.

How do I copy an example?

  1. Select the example in this article.

Important  Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In Excel, create a blank workbook or worksheet.
  3. In the worksheet, select cell A1, and press CTRL+V.

Important  For the example to work properly, you must paste it into cell A1 of the worksheet.

  1. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

5





6





7







8







9









10

A

B

C

Data



brook trout

Andreas

Hauser

species

Fourth

Pine

32



Formula

Description

Result

=CONCATENATE("Stream population for ",A2," ",A3," is ",A4,"/mile")

Creates a sentence by concatenating the data in column A with other text.

Stream population for brook trout species is 32/mile

 

=CONCATENATE(B2, " ", C2)

Concatenates the string in cell B2, a space character, and the value in cell C2.

Andreas Hauser

=CONCATENATE(C2, ", ", B2)

Concatenates the string in cell C2, a string consisting of a comma and a space character, and the value in cell B2.

Hauser, Andreas

=CONCATENATE(B3," & ",C3)

Concatenates the string in cell B3, a string consisting of a space, an ampersand, another space, and the value in cell C3.

Fourth & Pine

=B3 & " & " & C3

Concatenates the same items as the previous example, but by using the ampersand (&) calculation operator instead of the CONCATENATE function.

Fourth & Pine

Related Office Online discussions

Read related questions and answers from other Microsoft Office customers.


See Also




Excel > Function reference > Text and data

DOLLAR function

Excel 2007

The function described in this Help topic converts a number to text format and applies a currency symbol. The name of the function (and the symbol that it applies) depends upon your language settings.

This function converts a number to text using currency format, with the decimals rounded to the specified place. The format used is $#,##0.00_);($#,##0.00).

Syntax

DOLLAR(number,decimals)

Number   is a number, a reference to a cell containing a number, or a formula that evaluates to a number.

Decimals   is the number of digits to the right of the decimal point. If decimals is negative, number is rounded to the left of the decimal point. If you omit decimals, it is assumed to be 2.

Remark

The major difference between formatting a cell that contains a number by using a command (On the Home tab, in the Number group, click the arrow next to Number, and then click Number.) and formatting a number directly with the DOLLAR function is that DOLLAR converts its result to text. A number formatted with the Format Cells dialog box is still a number. You can continue to use numbers formatted with DOLLAR in formulas, because Microsoft Excel converts numbers entered as text values to numbers when it calculates.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

5

A


Data

1234.567

-1234.567

-0.123

99.888

Formula

Description (Result)

=DOLLAR(A2, 2)

Displays the first number in a currency format, 2 digits to the right of the decimal point ($1,234.57)

=DOLLAR(A2, -2)

Displays the first number in a currency format, 2 digits to the left of the decimal point ($1,200)

=DOLLAR(A3, -2)

Displays the second number in a currency format, 2 digits to the left of the decimal point (($1,200))

=DOLLAR(A4, 4)

Displays the third number in a currency format, 4 digits to the right of the decimal point(($0.1230))

=DOLLAR(A5)

Displays the fourth number in a currency format, 2 digit to the left of the decimal point ($99.89)


See Also




Excel > Function reference > Text and data

EXACT function

Excel 2007

Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise. EXACT is case-sensitive but ignores formatting differences. Use EXACT to test text being entered into a document.

Syntax

EXACT(text1,text2)

Text1   is the first text string.

Text2   is the second text string.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A

B

First string

Second string

word

word

Word

word

w ord

word

Formula

Description (Result)

=EXACT(A2,B2)

Checks whether the strings in the first row match (TRUE)

=EXACT(A3,B3)

Checks whether the strings in the second row match (FALSE)

=EXACT(A4,B4)

Checks whether the strings in the third row match (FALSE)


See Also




Excel > Function reference > Text and data

FIND, FINDB functions

Excel 2007

FIND and FINDB locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.

Important  FIND is intended for use with languages that use the single-byte character set (SBCS), whereas FINDB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

  • FIND always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
  • FINDB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, FINDB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

FIND(find_text,within_text,start_num)

FINDB(find_text,within_text,start_num)

Find_text   is the text you want to find.

Within_text   is the text containing the text you want to find.

Start_num   specifies the character at which to start the search. The first character in within_text is character number 1. If you omit start_num, it is assumed to be 1.

Remarks

  • FIND and FINDB are case sensitive and don't allow wildcard characters. If you don't want to do a case sensitive search or use wildcard characters, you can use SEARCH and SEARCHB.
  • If find_text is "" (empty text), FIND matches the first character in the search string (that is, the character numbered start_num or 1).
  • Find_text cannot contain any wildcard characters.
  • If find_text does not appear in within_text, FIND and FINDB return the #VALUE! error value.
  • If start_num is not greater than zero, FIND and FINDB return the #VALUE! error value.
  • If start_num is greater than the length of within_text, FIND and FINDB return the #VALUE! error value.
  • Use start_num to skip a specified number of characters. Using FIND as an example, suppose you are working with the text string "AYF0093.YoungMensApparel". To find the number of the first "Y" in the descriptive part of the text string, set start_num equal to 8 so that the serial-number portion of the text is not searched. FIND begins with character 8, finds find_text at the next character, and returns the number 9. FIND always returns the number of characters from the start of within_text, counting the characters you skip if start_num is greater than 1.

Example 1: FIND

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

A


Data

Miriam McGovern

Formula

Description (Result)

=FIND("M",A2)

Position of the first "M" in the string above (1)

=FIND("m",A2)

Position of the first "m" in the string above (6)

=FIND("M",A2,3)

Position of the first "M" in the string above, starting with the third character (8)

Example 2: FIND nested within MID

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A


Data

Ceramic Insulators #124-TD45-87

Copper Coils #12-671-6772

Variable Resistors #116010

Formula

Description (Result)

=MID(A2,1,FIND(" #",A2,1)-1)

Extracts text from position 1 to the position of "#" in the first string above (Ceramic Insulators)

=MID(A3,1,FIND(" #",A3,1)-1)

Extracts text from position 1 to the position of "#" in the second string above (Copper Coils)

=MID(A4,1,FIND(" #",A4,1)-1)

Extracts text from position 1 to the position of "#" in the third string above (Variable Resistors)

Example 3: FINDB (with your computer set to a default language that supports DBCS)

In the following example:

  • FINDB returns 3 because each character is counted by its bytes; the first character has 2 bytes, so the second character begins at byte 3.
  • FIND returns 2 because " " is in the second position within the string . FIND returns 2 no matter what the default language setting is on your computer.

=FINDB

("

"," ")

equals 3

=FIND(" "," ")

equals 2


See Also




Excel > Function reference > Text and data

FIXED function

Excel 2007

Rounds a number to the specified number of decimals, formats the number in decimal format using a period and commas, and returns the result as text.

Syntax

FIXED(number,decimals,no_commas)

Number   is the number you want to round and convert to text.

Decimals   is the number of digits to the right of the decimal point.

No_commas   is a logical value that, if TRUE, prevents FIXED from including commas in the returned text.

Remarks

  • Numbers in Microsoft Excel can never have more than 15 significant digits, but decimals can be as large as 127.
  • If decimals is negative, number is rounded to the left of the decimal point.
  • If you omit decimals, it is assumed to be 2.
  • If no_commas is FALSE or omitted, then the returned text includes commas as usual.
  • The major difference between formatting a cell containing a number by using a command (On the Home tab, in the Number group, click the arrow next to Number, and then click Number.) and formatting a number directly with the FIXED function is that FIXED converts its result to text. A number formatted with the Cells command is still a number.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A


Data

1234.567

-1234.567

44.332

Formula

Description (Result)

=FIXED(A2, 1)

Rounds the first number 1 digit to the right of the decimal point (1,234.6)

=FIXED(A2, -1)

Rounds the first number 1 digit to the left of the decimal point (1,230)

=FIXED(-1234.567, -1, TRUE)

Rounds the second number 1 digit to the left of the decimal point, without commas (-1230)

=FIXED(44.332)

Rounds the third number 2 digits to the left of the decimal point (44.33)


See Also




Excel > Function reference > Text and data

JIS function

The function described in this Help topic converts half-width (single-byte) letters within a character string to full-width (double-byte) characters. The name of the function (and the characters that it converts) depends upon your language settings.

For Japanese, this function changes half-width (single-byte) English letters or katakana within a character string to full-width (double-byte) characters.

Syntax

JIS(text)

Text   is the text or a reference to a cell that contains the text you want to change. If text does not contain any half-width English letters or katakana, text is not changed.

Example

=JIS("EXCEL")

equals "EXCEL"

=JIS("

")

equals " "


See Also




Excel > Function reference > Text and data

LEFT, LEFTB functions

Excel 2007

LEFT returns the first character or characters in a text string, based on the number of characters you specify.

LEFTB returns the first character or characters in a text string, based on the number of bytes you specify.

Important  LEFT is intended for use with languages that use the single-byte character set (SBCS), whereas LEFTB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

  • LEFT always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
  • LEFTB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, LEFTB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

LEFT(text,num_chars)

LEFTB(text,num_bytes)

Text   is the text string that contains the characters you want to extract.

Num_chars   specifies the number of characters you want LEFT to extract.

  • Num_chars must be greater than or equal to zero.
  • If num_chars is greater than the length of text, LEFT returns all of text.
  • If num_chars is omitted, it is assumed to be 1.

Num_bytes   specifies the number of characters you want LEFTB to extract, based on bytes.

Example 1: LEFT

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A


Data

Sale Price

Sweden

Formula

Description (Result)

=LEFT(A2,4)

First four characters in the first string (Sale)

=LEFT(A3)

First character in the second string (S)

Example 2: LEFTB (with your computer set to a default language that supports DBCS)

In the following example:

  • LEFTB returns the first 2 characters, because each character is counted as 2.
  • LEFT returns the first 4 characters, because each character is counted as 1. LEFT returns the first 4 characters no matter what the default language setting is on your computer.

=LEFTB(" ",4) equals "

"

=LEFT(" ",4) equals "

"


See Also




Excel > Function reference > Text and data

LEN, LENB functions

Excel 2007

LEN returns the number of characters in a text string.

LENB returns the number of bytes used to represent the characters in a text string.

Important  LEN is intended for use with languages that use the single-byte character set (SBCS), whereas LENB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

  • LEN always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
  • LENB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, LENB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

LEN(text)

LENB(text)

Text   is the text whose length you want to find. Spaces count as characters.

Example 1: LEN

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A


Data

Phoenix, AZ

 

   One  

Formula

Description (Result)

=LEN(A2)

Length of the first string (11)

=LEN(A3)

Length of the second string (0)

=LEN(A4)

Length of the third string, which includes 5 spaces (8)

Example 2: LENB (with your computer set to a default language that supports DBCS)

In the following example:

  • LENB returns 6, because each character is counted as 2.
  • LEN returns 3, because each character is counted as 1. LEN returns 3 no matter what the default language setting is on your computer.

=LENB(" ")

equals 6

=LEN(" ")

equals 3


See Also




Excel > Function reference > Text and data

LOWER function

Excel 2007

Converts all uppercase letters in a text string to lowercase.

Syntax

LOWER(text)

Text   is the text you want to convert to lowercase. LOWER does not change characters in text that are not letters.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A


Data

E. E. Cummings

Apt. 2B

Formula

Description (Result)

=LOWER(A2)

Lower case of first string (e. e. cummings)

=LOWER(A3)

Lower case of last string (apt. 2b)


See Also




Excel > Function reference > Text and data

MID, MIDB functions

Excel 2007

MID returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.

MIDB returns a specific number of characters from a text string, starting at the position you specify, based on the number of bytes you specify.

Important  MID is intended for use with languages that use the single-byte character set (SBCS), whereas MIDB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

  • MID always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
  • MIDB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, MIDB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

MID(text,start_num,num_chars)

MIDB(text,start_num,num_bytes)

Text   is the text string containing the characters you want to extract.

Start_num   is the position of the first character you want to extract in text. The first character in text has start_num 1, and so on.

Num_chars   specifies the number of characters you want MID to return from text.

Num_bytes   specifies the number of characters you want MIDB to return from text, in bytes.

Remarks

  • If start_num is greater than the length of text, MID returns "" (empty text).
  • If start_num is less than the length of text, but start_num plus num_chars exceeds the length of text, MID returns the characters up to the end of text.
  • If start_num is less than 1, MID returns the #VALUE! error value.
  • If num_chars is negative, MID returns the #VALUE! error value.
  • If num_bytes is negative, MIDB returns the #VALUE! error value.

Example 1: MID

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

A


Data

Fluid Flow

Formula

Description (Result)

=MID(A2,1,5)

Five characters from the string above, starting at the first character (Fluid)

=MID(A2,7,20)

Twenty characters from the string above, starting at the seventh (Flow)

=MID(A2,20,5)

Because the starting point is greater than the length of the string, empty text is returned ()

Example 2: MIDB (with your computer set to a default language that supports DBCS)

In the following example:

  • MIDB returns " " because each character is counted as 2; the second argument specifies a starting point at the fourth byte, which is the second character, and the third argument specifies a length of 2 bytes, which is one character.
  • MID returns " " because each character is counted as 1; the second argument specifies a starting point at the fourth character, and the third argument specifies a length of 2 characters. MID returns " " no matter what the default language setting is on your computer.

=MIDB(" ",4,2)

equals " "

=MID(" ",4,2)

equals " "


See Also




Excel > Function reference > Text and data

PHONETIC function

Extracts the phonetic (furigana) characters from a text string.

Syntax

PHONETIC(reference)

Reference   is a text string or a reference to a single cell or a range of cells that contain a furigana text string.

Remarks

  • If reference is a range of cells, the furigana text string in the upper-left corner cell of the range is returned.
  • If the reference is a range of nonadjacent cells, the #N/A error value is returned.

Example

If cells C4 contains " " and cell B7 contains " ", the following are true:

=PHONETIC(C4)

equals " "

=PHONETIC(B7)

equals " "


See Also




Excel > Function reference > Text and data

PROPER function

Excel 2007

Capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter. Converts all other letters to lowercase letters.

Syntax

PROPER(text)

Text   is text enclosed in quotation marks, a formula that returns text, or a reference to a cell containing the text you want to partially capitalize.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A


Data

this is a TITLE

2-cent's worth

76BudGet

Formula

Description (Result)

=PROPER(A2)

Proper case of first string (This Is A Title)

=PROPER(A3)

Proper case of second string (2-Cent'S Worth)

=PROPER(A4)

Proper case of third string (76Budget)


See Also




Excel > Function reference > Text and data

REPLACE, REPLACEB functions

Excel 2007

REPLACE replaces part of a text string, based on the number of characters you specify, with a different text string.

REPLACEB replaces part of a text string, based on the number of bytes you specify, with a different text string.

Important  REPLACE is intended for use with languages that use the single-byte character set (SBCS), whereas REPLACEB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

  • REPLACE always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
  • REPLACEB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, REPLACEB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

REPLACE(old_text,start_num,num_chars,new_text)

REPLACEB(old_text,start_num,num_bytes,new_text)

Old_text   is text in which you want to replace some characters.

Start_num   is the position of the character in old_text that you want to replace with new_text.

Num_chars   is the number of characters in old_text that you want REPLACE to replace with new_text.

Num_bytes   is the number of bytes in old_text that you want REPLACEB to replace with new_text.

New_text   is the text that will replace characters in old_text.

Example 1: REPLACE

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A


Data

abcdefghijk

2009

123456

Formula

Description (Result)

=REPLACE(A2,6,5,"*")

Replaces five characters, starting with the sixth character (abcde*k)

=REPLACE(A3,3,2,"10")

Replaces the last two digits of 2009 with 10 (2010)

=REPLACE(A4,1,3,"@")

Replaces the first three characters with @ (@456)

Example 2: REPLACEB (with your computer set to a default language that supports DBCS)

In the following example:

  • REPLACEB returns " " because each character is counted as 2; the second argument specifies a starting point at the fourth byte, which is the second character, and the third argument specifies a length of 4 bytes, which is two characters.
  • REPLACE returns " " because each character is counted as 1; the second argument specifies a starting point at the fourth character, and the third argument specifies a length of 4 characters. REPLACE returns " " no matter what the default language setting is on your computer.

=REPLACEB(" ",4,4," ")

equals " "

=REPLACE(" ",4,4," ")

equals " "


See Also




Excel > Function reference > Text and data

REPT function

Excel 2007

Repeats text a given number of times. Use REPT to fill a cell with a number of instances of a text string.

Syntax

REPT(text,number_times)

Text   is the text you want to repeat.

Number_times   is a positive number specifying the number of times to repeat text.

Remarks

  • If number_times is 0 (zero), REPT returns "" (empty text).
  • If number_times is not an integer, it is truncated.
  • The result of the REPT function cannot be longer than 32,767 characters, or REPT returns #VALUE!.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A

B

Formula

Description (Result)

=REPT("*-", 3)

Displays the string 3 times (*-*-*-)

=REPT("-",10)

Displays a dash 10 times (----------)


See Also




Excel > Function reference > Text and data

RIGHT, RIGHTB functions

Excel 2007

RIGHT returns the last character or characters in a text string, based on the number of characters you specify.

RIGHTB returns the last character or characters in a text string, based on the number of bytes you specify.

Important  RIGHT is intended for use with languages that use the single-byte character set (SBCS), whereas RIGHTB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

  • RIGHT always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
  • RIGHTB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, RIGHTB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

RIGHT(text,num_chars)

RIGHTB(text,num_bytes)

Text   is the text string containing the characters you want to extract.

Num_chars   specifies the number of characters you want RIGHT to extract.

Num_bytes   specifies the number of characters you want RIGHTB to extract, based on bytes.

Remarks

  • Num_chars must be greater than or equal to zero.
  • If num_chars is greater than the length of text, RIGHT returns all of text.
  • If num_chars is omitted, it is assumed to be 1.

Example 1: RIGHT

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A


Data

Sale Price

Stock Number

Formula

Description (Result)

=RIGHT(A2,5)

Last 5 characters of the first string (Price)

=RIGHT(A3)

Last character of the second string (r)

Example 2: RIGHTB (with your computer set to a default language that supports DBCS)

In the following example:

  • RIGHTB returns the last 2 characters, because each character is counted as 2.
  • RIGHT returns the last 4 characters, because each character is counted as 1. RIGHT returns the last 4 characters no matter what the default language setting is on your computer.

=RIGHTB(" ",4) equals "

"

=RIGHT(" ",4) equals "

"


See Also




Excel > Function reference > Text and data

SEARCH, SEARCHB functions

Excel 2007

This article describes the formula syntax and usage of the SEARCH and SEARCHB functions (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.) in Microsoft Office Excel.

Description

The SEARCH and SEARCHB functions locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. For example, to find the position of the letter "n" in the word "printer", you can use the following function:

=SEARCH("n","printer")

This function returns 4 because "n" is the fourth character in the word "printer."

You can also search for words within other words. For example, the function

=SEARCH("base","database")

returns 5, because the word "base" begins at the fifth character of the word "database". You can use the SEARCH and SEARCHB functions to determine the location of a character or text string within another text string, and then use the MID and MIDB functions to return the text, or use the REPLACE and REPLACEB functions to change the text. These functions are demonstrated in Example 1 in this article.

Important  The SEARCH function is intended for use with languages that use the single-byte character set (SBCS), whereas the SEARCHB function is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

  • SEARCH always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
  • SEARCHB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, SEARCHB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

For more information, see the following Help topics:

Syntax

SEARCH(find_text, within_text, [start_num])

SEARCHB(find_text, within_text, [start_num])

The SEARCH and SEARCHB function syntax has the following arguments (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.):

  • find_text  Required. The text that you want to find.
  • within_text  Required. The text in which you want to search for the value of the find_text argument.
  • start_num  Optional. The character number in the within_text argument at which you want to start searching.

Remarks

  • The SEARCH and SEARCHB functions are not case sensitive. If you want to do a case sensitive search, you can use FIND and FINDB.
  • You can use the wildcard characters  the question mark (?) and asterisk (* in the find_text argument. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.
  • If the value of find_text is not found, the #VALUE! error value is returned.
  • If the start_num argument is omitted, it is assumed to be 1.
  • If start_num is not greater than 0 (zero) or is greater than the length of the within_text argument, the #VALUE! error value is returned.
  • Use start_num to skip a specified number of characters. Using the SEARCH function as an example, suppose you are working with the text string "AYF0093.YoungMensApparel". To find the position of the first "Y" in the descriptive part of the text string, set start_num equal to 8 so that the serial number portion of the text (in this case, "AYF0093") is not searched. The SEARCH function starts the search operation at the eighth character position, finds the character that is specified in the find_text argument at the next position, and returns the number 9. The SEARCH function always returns the number of characters from the start of the within_text argument, counting the characters you skip if the start_num argument is greater than 1.

Example 1: SEARCH

The example may be easier to understand if you copy it to a blank worksheet.

How do I copy an example?

  1. Select the example in this article.

Important  Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In Excel, create a blank workbook or worksheet.
  3. In the worksheet, select cell A1, and press CTRL+V.

Important  For the example to work properly, you must paste it into cell A1 of the worksheet.

  1. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

5

6



7




8







9




10


11




12

A

B

C

Data



Statements



Profit Margin



margin



The "boss" is here.



Formula

Description

Result

=SEARCH("e",A2,6)

Position of the first "e" in the string in cell A2, starting at the sixth position.

7

=SEARCH(A4,A3)

Position of "margin" (string for which to search is cell A4) in "Profit Margin" (cell in which to search is A3).

8

=REPLACE(A3,SEARCH(A4,A3),6,"Amount")

Replaces "Margin" with "Amount" by first searching for the position of "Margin" in cell A3, and then replacing that character and the next five characters with the string "Amount."

Profit Amount

=MID(A3,SEARCH(" ",A3)+1,4)

Returns the first four characters that follow the first space character in "Profit Margin" (cell A3).

Marg

=SEARCH("""",A5)

Position of the first double quotation mark (") in cell A5.

5

=MID(A5,SEARCH("""",A5)+1,SEARCH("""",A5,SEARCH("""",A5)+1)-SEARCH("""",A5)-1)

Returns only the text enclosed in the double quotation marks in cell A5.

boss

Example 2: SEARCHB

Important  Your computer must be set to a default language that supports DBCS for this example to work.

In the following example:

  • The SEARCHB function returns 3 because each character is counted by its bytes; the first character has 2 bytes, so the second character begins at byte 3.
  • SEARCH returns 2 because " " is in the second position within the string. SEARCH returns 2 regardless of the default language setting on your computer.

=SEARCHB

("

"," ")

equals 3

=SEARCH(" "," ")

equals 2


See Also




Excel > Function reference > Text and data

SUBSTITUTE function

Excel 2007

Substitutes new_text for old_text in a text string. Use SUBSTITUTE when you want to replace specific text in a text string; use REPLACE when you want to replace any text that occurs in a specific location in a text string.

Syntax

SUBSTITUTE(text,old_text,new_text,instance_num)

Text   is the text or the reference to a cell containing text for which you want to substitute characters.

Old_text   is the text you want to replace.

New_text   is the text you want to replace old_text with.

Instance_num   specifies which occurrence of old_text you want to replace with new_text. If you specify instance_num, only that instance of old_text is replaced. Otherwise, every occurrence of old_text in text is changed to new_text.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A


Data

Sales Data

Quarter 1, 2008

Quarter 1, 2011

Formula

Description (Result)

=SUBSTITUTE(A2, "Sales", "Cost")

Substitutes Cost for Sales (Cost Data)

=SUBSTITUTE(A3, "1", "2", 1)

Substitutes first instance of "1" with "2" (Quarter 2, 2008)

=SUBSTITUTE(A4, "1", "2", 3)

Substitutes third instance of "1" with "2" (Quarter 1, 2012)


See Also




Excel > Function reference > Text and data

T function

Excel 2007

Returns the text referred to by value.

Syntax

T(value)

Value   is the value you want to test.

Remarks

  • If value is or refers to text, T returns value. If value does not refer to text, T returns "" (empty text).
  • You do not generally need to use the T function in a formula because Microsoft Excel automatically converts values as necessary. This function is provided for compatibility with other spreadsheet programs.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4

A


Data

Rainfall

19

TRUE

Formula

Description (Result)

=T(A2)

Because the first value is text, the text is returned (Rainfall)

=T(A3)

Because the second value is a number, empty text is returned ()

=T(A4)

Because the third value is a logical value, empty text is returned ()


See Also




Excel > Function reference > Text and data

TEXT function

Excel 2007

This article describes the formula syntax and usage of the TEXT function (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.) in Microsoft Office Excel.

Description

The TEXT function converts a numeric value to text and lets you specify the display formatting by using special format strings. This function is useful in situations where you want to display numbers in a more readable format, or you want to combine numbers with text or symbols. For example, suppose cell A1 contains the number 23.5. To format the number as a dollar amount, you can use the following formula:

=TEXT(A1,"$0.00")

In this example, Excel displays $23.50.

You can also format numbers by using the commands in the Number group on the Home tab of the Ribbon. However, these commands work only if the entire cell is numeric. If you want to format a number and combine it with other text, the TEXT function is the best option. For example, you can add text to the preceding formula:

=TEXT(A1,"$0.00") & " per hour"

Excel displays $23.50 per hour.

Syntax

TEXT(value, format_text)

The TEXT function syntax has the following arguments (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.):

  • value  Required. A numeric value, a formula that evaluates to a numeric value, or a reference to a cell containing a numeric value.
  • format_text  Required. A numeric format as a text string enclosed in quotation marks, for example "m/d/yyyy" or "#,##0.00". See the following sections for specific formatting guidelines.

Guidelines for number formats

    • Display decimal places and significant digits  To format fractions or numbers that contain decimal points, include the following digit placeholders, decimal points, and thousand separators in the format_text argument.

Placeholder

Description

0 (zero)

Displays insignificant zeros if a number has fewer digits than there are zeros in the format. For example, if you type 8.9, and you want it to be displayed as 8.90, use the format #.00.

#

Follows the same rules as the 0 (zero). However, Excel does not display extra zeros when the number that you type has fewer digits on either side of the decimal than there are # symbols in the format. For example, if the custom format is #.##, and you type 8.9 in the cell, the number 8.9 is displayed.

?

Follows the same rules as the 0 (zero). However, Excel adds a space for insignificant zeros on either side of the decimal point so that decimal points are aligned in the column. For example, the custom format 0.0? aligns the decimal points for the numbers 8.9 and 88.99 in a column.

. (period)

Displays the decimal point in a number.

    • If a number has more digits to the right of the decimal point than there are placeholders in the format, the number rounds to as many decimal places as there are placeholders. If there are more digits to the left of the decimal point than there are placeholders, the extra digits are displayed. If the format contains only number signs (#) to the left of the decimal point, numbers less than 1 begin with a decimal point; for example, .47.

To display

As

Use this format

1234.59

1234.6

"####.#"

8.9

8.900

"#.000"

0.631

0.6

"0.#"

12
1234.568   

12.0
1234.57

"#.0#"

44.398
102.65
2.8

  44.398
102.65
    2.8
(with aligned decimals)

"???.???"

5.25
5.3

5 1/4
5 3/10
(with aligned fractions)

"# ???/???"

    • Display a thousands separator  To display a comma as a thousands separator or to scale a number by a multiple of 1,000, include the following separator in the number format.

, (comma)

Displays the thousands separator in a number. Excel separates thousands by commas if the format contains a comma that is enclosed by number signs (#) or by zeros. A comma that follows a digit placeholder scales the number by 1,000. For example, if the format_text argument is "#,###.0,", Excel displays the number 12,200,000 as 12,200.0.

To display

As

Use this format

12000

12,000

"#,###"

12000

12

"#,"

12200000

12.2

"0.0,,"


Guidelines for date and time formats

    • Display days, months, and years  To display numbers as date formats (such as days, months, and years), use the following codes in the format_text argument.

m

Displays the month as a number without a leading zero.





mm

Displays the month as a number with a leading zero when appropriate.





mmm

Displays the month as an abbreviation (Jan to Dec).





mmmm

Displays the month as a full name (January to December).





mmmmm

Displays the month as a single letter (J to D).





d

Displays the day as a number without a leading zero.





dd

Displays the day as a number with a leading zero when appropriate.





ddd

Displays the day as an abbreviation (Sun to Sat).





dddd

Displays the day as a full name (Sunday to Saturday).





yy

Displays the year as a two-digit number.





yyyy

Displays the year as a four-digit number.




To display

As

Use this format

Months

112

"m"

Months

0112

"mm"

Months

JanDec

"mmm"

Months

JanuaryDecember

"mmmm"

Months

JD

"mmmmm"

Days

131

"d"

Days

0131

"dd"

Days

SunSat

"ddd"

Days

SundaySaturday

"dddd"

Years

0099

"yy"

Years

19009999

"yyyy"

    • Display hours, minutes, and seconds  To display time formats (such as hours, minutes, and seconds), use the following codes in the format_text argument.

h

Displays the hour as a number without a leading zero.

[h]

Displays elapsed time in hours. If you are working with a formula that returns a time in which the number of hours exceeds 24, use a number format that resembles [h]:mm:ss.

hh

Displays the hour as a number with a leading zero when appropriate. If the format contains AM or PM, the hour is shown based on the 12-hour clock. Otherwise, the hour is shown based on the 24-hour clock.

m

Displays the minute as a number without a leading zero.

 Note    The m or the mm code must appear immediately after the h or hh code or immediately before the ss code; otherwise, Excel displays the month instead of minutes.

[m]

Displays elapsed time in minutes. If you are working with a formula that returns a time in which the number of minutes exceeds 60, use a number format that resembles [mm]:ss.

mm

Displays the minute as a number with a leading zero when appropriate.

 Note    The m or the mm code must appear immediately after the h or hh code or immediately before the ss code; otherwise, Excel displays the month instead of minutes.

s

Displays the second as a number without a leading zero.

[s]

Displays elapsed time in seconds. If you are working with a formula that returns a time in which the number of seconds exceeds 60, use a number format that resembles [ss].

ss

Displays the second as a number with a leading zero when appropriate. If you want to display fractions of a second, use a number format that resembles h:mm:ss.00.

AM/PM, am/pm, A/P, a/p

Displays the hour based on a 12-hour clock. Excel displays AM, am, A, or a for times from midnight until noon and PM, pm, P, or p for times from noon until midnight.

To display

As

Use this format

Hours

023

"h"

Hours

0023

"hh"

Minutes

059

"m"

Minutes

0059

"mm"

Seconds

059

"s"

Seconds

0059

"ss"

Time

4 AM

"h AM/PM"

Time

4:36 PM

"h:mm AM/PM"

Time

4:36:03 P

"h:mm:ss A/P"

Time

4:36:03.75

"h:mm:ss.00"

Elapsed time (hours and minutes)

1:02

"[h]:mm"

Elapsed time (minutes and seconds)

62:16

"[mm]:ss"

Elapsed time (seconds and hundredths)

3735.80

"[ss].00"

Guidelines for currency, percentages, and scientific notation format

    • Include currency symbols  To precede a number with a dollar sign ($), type the dollar sign at the beginning of the format_text argument (for example, "$#,##0.00"). To enter one of the following currency symbols in a number format, press NUM LOCK and use the numeric keypad to type the ANSI code for the symbol.

To enter

Use this key combination


¢

ALT+0162


£

ALT+0163


¥

ALT+0165


ALT+0128


    •  Note    You must use the numeric keypad; using the ALT key with the number keys in the top row of the keyboard will not generate ANSI codes.
    • Display percentages  To display numbers as a percentage of 100  for example, to display .08 as 8% or 2.8 as 280%  include the percent sign (%) in the format_text argument.
    • Display scientific notations  To display numbers in scientific (exponential) format, use the following exponent codes in the format_text argument.

E (E-, E+, e-, e+)

Displays a number in scientific (exponential) format. Excel displays a number to the right of the "E" or "e" that corresponds to the number of places that the decimal point was moved. For example, if the format_text argument is "0.00E+00", Excel displays the number 12,200,000 as 1.22E+07. If you change the format_text argument to "#0.0E+0", Excel displays 12.2E+6.

Guidelines for including text and adding spacing

    • If you include any of the following characters in the format_text argument, they are displayed exactly as entered.

$

Dollar sign

+

Plus sign

(

Left parenthesis

:

Colon

^

Circumflex accent (caret)

'

Apostrophe

{

Left curly bracket

<

Less-than sign

=

Equal sign

-

Minus sign

/

Slash mark

)

Right parenthesis

!

Exclamation point

&

Ampersand

~

Tilde

}

Right curly bracket

>

Greater-than sign

 

Space character

 Notes 

  • The format_text argument cannot contain an asterisk (*).
  • Using the TEXT function converts a numeric value to formatted text, and the result can no longer be calculated as a number. To format a cell so that its value remains numeric, right-click the cell, click Format Cells, and then in the Format Cells dialog box, on the Number tab, set the formatting options you want. For more information about using the Format Cells dialog box, click the Help button (?) in the upper right corner of the dialog box.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How do I copy an example?

  1. Select the example in this article.

Important  Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In Excel, create a blank workbook or worksheet.
  3. In the worksheet, select cell A1, and press CTRL+V.

Important  For the example to work properly, you must paste it into cell A1 of the worksheet.

  1. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

4





5





6



7



8



9



10

A

B

C

Salesperson

Sales

Data

Burke

2800

39300.625

Dykstra

40%


Formula

Description

Result

=A2&" sold "&TEXT(B2, "$0.00")&" worth of units."

Combines cell A2, the text string " sold," cell B2 (formatted as currency), and the text string " worth of units." into a phrase.

Burke sold $2800.00 worth of units.

=A3&" sold "&TEXT(B3,"0%")&" of the total sales."

Combines cell A3, the string " sold," cell B3 (formatted as a percentage), and the text string " of the total sales." into a phrase.

Dykstra accounted for 40% of the total sales.

="Date: " & TEXT(C2,"yyyy-mm-dd")

Displays the value in C2 in a 4-digit year, 2-digit month, 2-digit day format.

Date: 2007-08-06

="Date-time: " & TEXT(C2,"m/d/yyyy h:mm AM/PM")

Displays the value in C2 in a short date, 12-hour time format.

Date-time: 8/6/2007 3:00 PM

=TEXT(C2,"0.00E+00")

Displays the value in C2 in scientific (exponential) format.

3.93E+04

TEXT(C2,"$#,##0.00")

Displays the value in C2 in a currency format, with a thousands separator.

$39,300.63



See Also




Excel > Function reference > Text and data

TRIM function

Excel 2007

Removes all spaces from text except for single spaces between words. Use TRIM on text that you have received from another application that may have irregular spacing.

Important  The TRIM function was designed to trim the 7-bit ASCII space character (value 32) from text. In the Unicode character set, there is an additional space character called the nonbreaking space character that has a decimal value of 160. This character is commonly used in Web pages as the HTML entity, &nbsp;. By itself, the TRIM function does not remove this nonbreaking space character. For an example of how to trim both space characters from text, see Remove spaces and nonprinting characters from text.

Syntax

TRIM(text)

Text   is the text from which you want spaces removed.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

A

B

Formula

Description (Result)

=TRIM(" First Quarter Earnings ")

Removes leading and trailing spaces from the text in the formula (First Quarter Earnings)


See Also




Excel > Function reference > Text and data

UPPER function

Excel 2007

Converts text to uppercase.

Syntax

UPPER(text)

Text   is the text you want converted to uppercase. Text can be a reference or text string.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A


Data

total

Yield

Formula

Description (Result)

=UPPER(A2)

Upper case of first string (TOTAL)

=UPPER(A3)

Upper case of second string (YIELD)





Excel > Function reference > Text and data

VALUE function

Excel 2007

Converts a text string that represents a number to a number.

Syntax

VALUE(text)

Text   is the text enclosed in quotation marks or a reference to a cell containing the text you want to convert.

Remarks

  • Text can be in any of the constant number, date, or time formats recognized by Microsoft Excel. If text is not in one of these formats, VALUE returns the #VALUE! error value.
  • You do not generally need to use the VALUE function in a formula because Excel automatically converts text to numbers as necessary. This function is provided for compatibility with other spreadsheet programs.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How to copy an example

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic.

 Note    Do not select the row or column headers.

Selecting an example from Help

  1. Press CTRL+C.
  2. In the worksheet, select cell A1, and press CTRL+V.
  3. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

 

1

2

3

A

B

Formula

Description (Result)

=VALUE("$1,000")

Number equivalent of the string (1000)

=VALUE("16:48:00")-VALUE("12:00:00")

The serial number equivalent to 4 hours and 48 minutes, which is "16:48:00"-"12:00:00" (0.2 or 4:48)

 Note    To view the number as a time, select the cell, and then on the Home tab, in the Number group, click the arrow next to Number Format, and click Time.



Microsoft® and Microsoft Excel® are registered trademarks of Microsoft Corporation.
©2003-2009 LikeOffice -
Privacy Policy - Contact us

[Top]