How to Remove Spaces From the Beginning and End of a Cell in Excel 2007

2
By: Harvinder Singh H OW TO R EMOVE SPACES F OF A CELL IN E XCEL 2007 Sometimes text values contain leadin set (Unicode: A character encoding st byte to represent each character, Un represented by using a single chara character set values 0 to 31, 127, 1 unexpected results when you sort, fi inadvertently adding extra space ch nonprinting characters embedded unexpected results may be difficult combination of the TRIM, CLEAN, and The TRIM function removes spaces f removes all nonprintable characters which is a subset of the ANSI charac Windows that allows you to represe ASCII character set is a subset of the 127) in 7-bit ASCII represent the same The TRIM function was designed to tr character set, there is an additional decimal value of 160. This character the TRIM function does not remove th The CLEAN function was designed to (values 0 through 31) from text. In t (values 127, 129, 141, 143, 144, and nonprinting characters. To do this task, use the SUBSTITUTE ASCII characters for which the TRIM a Example The example may be easier to un How to copy an example 1. Create a blank workbook or w 2. Select the example in the He Note Do not select the row or c Selecting an example from Help FROM TH E BEGINNING AND END ng, trailing, or multiple embedded space charac tandard developed by the Unicode Consortium. nicode enables almost all of the written langu acter set.) Values 32 and 160), or non-printi 129, 141, 143, 144, and 157). These character ilter, or search. For example, users may make haracters, or imported text data from extern in the text. Because these characters are to understand. To remove these unwanted ch d SUBSTITUTE functions. from text except for single spaces between wo s from text. Both functions were designed to cter set (ANSI character set: An 8-bit characte ent up to 256 characters (0 through 255) by us e ANSI set.). It's important to understand that t e characters as the first 128 values in the Unicod rim the 7-bit ASCII space character (value 32) fr al space character called the nonbreaking spa is commonly used in Web pages as the HTML his nonbreaking space character. o remove the first 32 non-printing characters the Unicode character set, there are additiona d 157). By itself, the CLEAN function does not r function to replace the higher value Unicode c and CLEAN functions were designed. nderstand if you copy it to a blank worksheet. worksheet. elp topic. column headers. p 1 cters (Unicode character . By using more than one uages in the world to be ing characters (Unicode rs can sometimes cause e typographical errors by nal sources may contain not easily noticed, the haracters, you can use a ords. The CLEAN function o work with 7-bit ASCII, er set used by Microsoft sing your keyboard. The the first 128 values (0 to de character set. rom text. In the Unicode ace character that has a entity,  . By itself, s in the 7 bit ASCII code al nonprinting characters remove these additional characters with the 7-bit

description

How to Remove spaces from the beginning and end of a cell in Excel 2007

Transcript of How to Remove Spaces From the Beginning and End of a Cell in Excel 2007

Page 1: How to Remove Spaces From the Beginning and End of a Cell in Excel 2007

By: Harvinder Singh

HOW TO REMOVE SPACES FROM TH

OF A CELL IN EXCEL 2007

Sometimes text values contain leading, trailing, or multiple embedded space characters

set (Unicode: A character encoding standard developed by the Unicode Consortium. By using more than one

byte to represent each character, Unicode enab

represented by using a single character set.)

character set values 0 to 31, 127, 129, 141, 143, 144, and 157). These characters can sometimes

unexpected results when you sort, filter, or search. For example, users may make typographical errors by

inadvertently adding extra space characters, or imported text data from external sources may contain

nonprinting characters embedded in the text

unexpected results may be difficult to understand. To remove these unwanted characters, you can use a

combination of the TRIM, CLEAN, and SUBSTITUTE functions.

The TRIM function removes spaces from t

removes all nonprintable characters from text

which is a subset of the ANSI character set (ANSI character set: An 8

Windows that allows you to represent up to 256 characters (0 through 255) by using your keyboard

ASCII character set is a subset of the ANSI set.). It's important to understand that the first 128 values (0 to

127) in 7-bit ASCII represent the same characters as the first 128 values in the Unicode character set.

The TRIM function was designed to trim the 7

character set, there is an additional space character called the nonbr

decimal value of 160. This character is commonly used in Web pages as the HTML entity,  . By itself,

the TRIM function does not remove this nonbreaking space character.

The CLEAN function was designed to remove the

(values 0 through 31) from text. In the Unicode character set, there are additional nonprinting characters

(values 127, 129, 141, 143, 144, and 157). By itself, the CLEAN function does not remove the

nonprinting characters.

To do this task, use the SUBSTITUTE function

ASCII characters for which the TRIM and CLEAN functions were designed.

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

EMOVE SPACES FROM THE BEGINNING AND END

leading, trailing, or multiple embedded space characters

(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.) Values 32 and 160), or non-printing characters (Unicode

character set values 0 to 31, 127, 129, 141, 143, 144, and 157). These characters can sometimes

unexpected results when you sort, filter, or search. For example, users may make typographical errors by

inadvertently adding extra space characters, or imported text data from external sources may contain

nonprinting characters embedded in the text. Because these characters are not easily noticed, the

unexpected results may be difficult to understand. To remove these unwanted characters, you can use a

combination of the TRIM, CLEAN, and SUBSTITUTE functions.

spaces from text except for single spaces between words

nonprintable characters from text. Both functions were designed to work with 7

subset of the ANSI character set (ANSI character set: An 8-bit character set use

Windows that allows you to represent up to 256 characters (0 through 255) by using your keyboard

ASCII character set is a subset of the ANSI set.). It's important to understand that the first 128 values (0 to

nt the same characters as the first 128 values in the Unicode character set.

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,  . By itself,

the TRIM function does not remove this nonbreaking space character.

The CLEAN function was designed to remove the first 32 non-printing characters in the 7 bit ASCII code

(values 0 through 31) from text. In the Unicode character set, there are additional nonprinting characters

(values 127, 129, 141, 143, 144, and 157). By itself, the CLEAN function does not remove the

SUBSTITUTE function to replace the higher value Unicode characters with the 7

ASCII characters for which the TRIM and CLEAN functions were designed.

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

Create a blank workbook or worksheet.

Select the example in the Help topic.

Note Do not select the row or column headers.

Help

1

leading, trailing, or multiple embedded space characters (Unicode character

(Unicode: A character encoding standard developed by the Unicode Consortium. By using more than one

les almost all of the written languages in the world to be

printing characters (Unicode

character set values 0 to 31, 127, 129, 141, 143, 144, and 157). These characters can sometimes cause

unexpected results when you sort, filter, or search. For example, users may make typographical errors by

inadvertently adding extra space characters, or imported text data from external sources may contain

. Because these characters are not easily noticed, the

unexpected results may be difficult to understand. To remove these unwanted characters, you can use a

single spaces between words. The CLEAN function

designed to work with 7-bit ASCII,

bit character set used by Microsoft

Windows that allows you to represent up to 256 characters (0 through 255) by using your keyboard. The

ASCII character set is a subset of the ANSI set.). It's important to understand that the first 128 values (0 to

nt the same characters as the first 128 values in the Unicode character set.

bit ASCII space character (value 32) from text. In the Unicode

eaking space character that has a

decimal value of 160. This character is commonly used in Web pages as the HTML entity,  . By itself,

printing characters in the 7 bit ASCII code

(values 0 through 31) from text. In the Unicode 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

to replace the higher value Unicode characters with the 7-bit

Page 2: How to Remove Spaces From the Beginning and End of a Cell in Excel 2007

By: Harvinder Singh

HOW TO REMOVE SPACES FROM TH

OF A CELL IN EXCEL 2007

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

Show Formulas button.

1 Data

2 BD 122

3 ="XY"&CHAR(7)&"453"

4 BD 122

MN 987

Formula

=TRIM(A2)

=CLEAN(A3)

=TRIM(SUBSTITUTE(A4,CHAR(160),CHAR(32)))

=CLEAN(SUBSTITUTE(A5,CHAR(127),CHAR(7)))

EMOVE SPACES FROM THE BEGINNING AND END

In the worksheet, select cell A1, and press CTRL+V.

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

Description (Result)

Removes the trailing space from the string "BD 122 "

(BD 112)

Removes the nonprinting BEL character (ASCII value of

7) from the string value created by the expression

="XY"&CHAR(7)&"453" (XY453)

=TRIM(SUBSTITUTE(A4,CHAR(160),CHAR(32))) Replaces each nonbreaking space character (Unicode

value of 160) with a space character (ASCII value of 32)

by using the SUBSTITUTE function, and then removes

the leading and multiple embedded spaces from the

string " BD 122" (BD 112)

=CLEAN(SUBSTITUTE(A5,CHAR(127),CHAR(7))) Replaces the nonprinting DEL character (ASCII

127) with a BEL character (ASCII value of 7) by using the

SUBSTITUTE function, and then removes the BEL

character from the string "MN

2

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

Removes the trailing space from the string "BD 122 "

Removes the nonprinting BEL character (ASCII value of

value created by the expression

="XY"&CHAR(7)&"453" (XY453)

Replaces each nonbreaking space character (Unicode

space character (ASCII value of 32)

by using the SUBSTITUTE function, and then removes

the leading and multiple embedded spaces from the

Replaces the nonprinting DEL character (ASCII value of

127) with a BEL character (ASCII value of 7) by using the

SUBSTITUTE function, and then removes the BEL

character from the string "MN 987" (MN987