Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Unexpected Behavior with Numbers Formatted as Text


View products that this article applies to.

This article was previously published under Q181226

↑ Back to the top


Symptoms

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

↑ Back to the top


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.

↑ Back to the top


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:
  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:
    Sub Enter_Values()
        For Each xCell In Selection
            xCell.Value = xCell.Value
        Next xCell
    End Sub
    					
  6. Press ALT+F11 to switch to Microsoft Excel.
  7. Reselect the affected cells if they are not already selected.
  8. On the Tools menu, point to Macro, and then click Macros. In the Macro Name list, click Enter_Values. Click Run.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB181226, kbprb

↑ Back to the top

Article Info
Article ID : 181226
Revision : 4
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 345