Microsoft KB Archive/181226

= XL2000: Unexpected Behavior with Numbers Formatted as Text =

Article ID: 181226

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q181226



SYMPTOMS
When you attempt to change the number format of a cell, the number format may not change as you expect.



CAUSE
This behavior occurs when the following conditions are true:
 * The cell is formatted with the Text format.

-or-


 * The underlying value in the cell is text.

When you format a cell by using the Text number format, the cell is changed, and anything you enter in the cell is displayed as text.



WORKAROUND
To work around this behavior, use any of the following methods.

Method 1: Retyping the Values in the Cells
On the Format menu, click Cells, and click the Number tab to change the number format of the cells. Then, retype the numbers.

Method 2: Select Edit Directly In Cell
To use this method, follow these steps:
 * 1) On the Tools menu, click Options.
 * 2) On the Edit tab, verify that the Edit Directly In Cell check box is selected. Click OK.
 * 3) Double-click the cell you want to format, and then press ENTER.

Method 3: Using Paste Special with Multiply
To use this method, follow these steps:
 * 1) In any blank cell, enter the value 1.
 * 2) Select the cell in which you typed 1 and click Copy on the Edit menu.
 * 3) Select the cells with the values that you want to convert to numbers.
 * 4) On the Edit menu, click Paste Special.
 * 5) Under Operation, click Multiply. Under Paste, click Values and then click OK.

Method 4: Use a Visual Basic for Applications Procedure
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Create a Visual Basic for Applications macro to reenter the numbers in the selected cell or range of cells. To do this, follow these steps:  Select the cells that exhibit the behavior. If you have not already done so, click Cells on the Format menu and click the Number tab to change the number format of the cells. Press ALT+F11 to open the Visual Basic Editor. On the Insert menu, click Module.  Type the following macro code in the new module: Sub Enter_Values For Each xCell In Selection xCell.Value = xCell.Value Next xCell End Sub  Press ALT+F11 to switch to Microsoft Excel.</li> Reselect the affected cells if they are not already selected.</li> On the Tools menu, point to Macro, and then click Macros. In the Macro Name list, click Enter_Values. Click Run.</li></ol>

<div class="moreinformation_section">

MORE INFORMATION
To format a number as text, follow these steps:
 * 1) Select a single cell or a range of cells.
 * 2) On the Format menu, click Cells.
 * 3) Click the Number tab, click Text, and then click OK.
 * 4) In the cell or range of cells you selected, type numeric values.

After you follow these steps, you cannot change the format back to a number without reentering the numbers.

NOTE: If you enter the numbers before you format the cells to use the Text number format, the data you enter remains numeric; however, Microsoft Excel aligns the numbers to the left in the cells so that the numbers appear as text.

<div class="references_section">