XL97: "255 Characters in Cell" Error when Copying Worksheet

Last reviewed: March 13, 1998
Article ID: Q159729
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you copy a worksheet in Microsoft Excel 97, you may receive the following error message:

   The sheet you are copying contains cells that have more than 255
   characters in them. Copying an entire sheet truncates cells that
   contain more than 255 characters.

   To avoid truncation, copy the cells of the source sheet to the
   destination (rather than copying the entire sheet).

Cells in the new worksheet are all truncated so that they contain no more than 255 characters.

CAUSE

This will occur if one or both of the following conditions are true:

  • One or more cells in the worksheet contains a string of characters that exceeds 255 characters in length. For example: a string of 300 "x" characters or a very long sentence.

    -or-

  • One or more cells in the worksheet contains a formula whose length exceeds 255 characters. For example: =SUM(A1+A2+A3+...+A100)

WORKAROUND

If you manually copy a worksheet and receive this error message, use the following steps to make the new worksheet identical to the original worksheet:

  1. In the error message dialog box, click OK.

  2. Activate the original worksheet.

  3. Press CTRL+a or click the Select All button in the upper-left corner of the worksheet.

  4. On the Edit menu, click Copy.

  5. Activate the new worksheet and select cell A1.

  6. On the Edit menu, click Paste.

The new worksheet should now be identical to the original worksheet.

If cells in your worksheet are truncated when you use a Visual Basic macro to copy a worksheet, you can modify the macro so that it copies the sheet successfully. The following sample subroutine demonstrates how you can do this.

Microsoft provides examples of Visual Basic for Applications procedures 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. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

    Sub Test()

        'Turn off screen updating while the macro runs.
        Application.ScreenUpdating = False

        'xSheet is the sheet we want to copy.
        Set xSheet = ActiveSheet

        'Copy the worksheet to the desired destination. Cells with more
        'than 255 characters will be truncated by this step.
        xSheet.Copy Before:=Sheets(xSheet.Index)

        'ySheet is the new worksheet.
        Set ySheet = ActiveSheet

        'Copy all of the cells on the original worksheet...
        xSheet.Range("A:IV").Copy

        '...activate the new worksheet...
        ySheet.Range("A1").Select

        '...and paste the copied cells. All cells in the new worksheet
        'now have the correct contents.
        ySheet.Paste

        'Clear out the clipboard and select cell A1.
        Application.CutCopyMode = False
        Range("A1").Select

    End Sub

STATUS

This behavior is by design of Microsoft Excel 97.

MORE INFORMATION

If you use a Visual Basic macro to copy a worksheet, you do not receive the error message shown above. However, cells in your worksheet are still truncated to 255 characters.

Note that a short formula that returns a long string of characters does not cause this problem to occur. For example: the formula =REPT("x",400) returns a string of 400 "x" characters, but copying a sheet containing this formula does not cause the problem to occur.

Note also that this problem does not occur if you move a worksheet from one workbook to another, or if you move it within the same workbook. The problem only occurs when you copy a worksheet.


Additional query words: XL97 8.00
Keywords : xlvbainfo xlui
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.