Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Substitute worksheet function considered harmful: can create     unopenable workbooks with cell values greater than 32k

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alok - 05 Dec 2007 15:22 GMT
The following macro will create a value in cell A2 that has more than
32k characters.

Sub foo()
   Range("A1").Value = String$(2 ^ 15 - 1, "a")
   Range("A2").Formula = "=Substitute(A1, ""a"", ""ab"")"
   Range("A3").Formula = "=len(A2)"
End Sub

If you now save this workbook, it will not be openable by excel. We
discovered this behavior quite by accident when replacing the tab
character in a cell with spaces. Unfortunately, the cell contained a
large text fragment, and when expanded it was >32k chars. Because the
workbook is fine until it is saved and reopened, and because the
worksheet had nearly 1 million cells, it took a while to track down.
Are there other ways to make seemingly valid workbooks that cannot be
opened?
Niek Otten - 05 Dec 2007 16:28 GMT
In Excel 2003 I do get a message on opening "Data may be lost", but it opens and A3 is 65534

Signature

Kind regards,

Niek Otten
Microsoft MVP - Excel

| The following macro will create a value in cell A2 that has more than
| 32k characters.
[quoted text clipped - 13 lines]
| Are there other ways to make seemingly valid workbooks that cannot be
| opened?
Alok - 26 Dec 2007 22:41 GMT
> In Excel 2003 I do get a message on opening "Data may be lost", but it opens and A3 is 65534
>
[quoted text clipped - 21 lines]
> | Are there other ways to make seemingly valid workbooks that cannot be
> | opened?

Ah! I ran windows update, and it was able to open it. Apparently, one
of the updates fixed it. Thanks for pointing this out!
Bill Renaud - 05 Dec 2007 16:49 GMT
Very interesting!!!

It opens fine for me in Excel 2000 (SP-3).

Signature

Regards,
Bill Renaud

Bill Renaud - 05 Dec 2007 16:50 GMT
Cell A3 is 32767.

Signature

Regards,
Bill Renaud

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.