XL2000: Unexpected Behavior with Numbers Formatted as Text

ID: Q181226


The information in this article applies to:
  • Microsoft Excel 2000


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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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:
  1. Select the cells that exhibit the behavior.


  2. 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.


  3. Press ALT+F11 to open the Visual Basic Editor.


  4. On the Insert menu, click Module.


  5. Type the following macro code in the new module:


  6. 
    Sub Enter_Values()
        For Each xCell In Selection
            xCell.Value = xCell.Value
        Next xCell
    End Sub 
  7. Press ALT+F11 to switch to Microsoft Excel.


  8. Reselect the affected cells if they are not already selected.


  9. On the Tools menu, point to Macro, and then click Macros. In the Macro Name list, click Enter_Values. Click Run.



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.


REFERENCES

For more information about number formats, click Microsoft Excel Help on the Help menu, type "About number formats" in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: XL2000

Keywords : xlformat
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: July 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.