XL98: Len Function Returns Only 255 Characters in Cell

Last reviewed: March 16, 1998
Article ID: Q182481
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

In a Microsoft Visual Basic for Applications macro in Microsoft Excel 98 Macintosh Edition, if you use the Len function to calculate the number of characters in an object, such as a cell, you may receive the incorrect result, 255.

CAUSE

This occurs if the following conditions are true:

  • The object contains more than 255 characters.

        -and-
    
  • You use the Text property of the object inside the Len function, for example, Len(ActiveCell.Text).

The Text property of an object returns only the first 255 characters in the object.

WORKAROUND

To determine the correct number of characters within an object, use the Value property within the Len function, as in the following example:

   Len(ActiveCell.Value)

STATUS

This behavior is by design of the Text property in Microsoft Excel 98 Macintosh Edition.

MORE INFORMATION

You can use the Len function in Visual Basic for Applications to calculate the number of characters within a cell in a worksheet or within any other object that contains text.

If you use the Len function to calculate the number of characters contained in an object, and if you use the Text property of the object, the maximum result is 255. This may cause problems if the object in question contains more than 255 characters.

For additional information about the Text property in Microsoft Excel, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q182483
   TITLE     : XL98: Text Property Limited to 255 Characters


Additional query words: XL98 32,767 length
Keywords : kbprg kbdta xlvbahowto xlvbainfo
Version : MACINTOSH:98
Platform : MACINTOSH
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 16, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.