Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Substitute worksheet function considered harmful: can createunopenable workbooks with cell values greater than 32k

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Substitute worksheet function considered harmful: can create unopenable workbooks with cell values greater than 32k

In Excel 2003 I do get a message on opening "Data may be lost", but it opens and A3 is 65534

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Alok" wrote in message ...
| 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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Substitute worksheet function considered harmful: can create unopenable workbooks with cell values greater than 32k

Very interesting!!!

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

--
Regards,
Bill Renaud



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Substitute worksheet function considered harmful: can create unopenable workbooks with cell values greater than 32k

Cell A3 is 32767.

--
Regards,
Bill Renaud



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Substitute worksheet function considered harmful: can createunopenable workbooks with cell values greater than 32k

On Dec 5, 11:28 am, "Niek Otten" wrote:
In Excel 2003 I do get a message on opening "Data may be lost", but it opens and A3 is 65534

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Alok" wrote in ...

| 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?


Ah! I ran windows update, and it was able to open it. Apparently, one
of the updates fixed it. Thanks for pointing this out!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to substitute a value for calculation with a column of values Peiru Excel Worksheet Functions 1 April 2nd 06 02:02 PM
message 'hyperlink can be harmful warning..etc...' ljmccrary Excel Discussion (Misc queries) 2 March 24th 05 06:29 PM
what is used for cell entries that are considered subsections of . dovie1957 Excel Discussion (Misc queries) 1 March 16th 05 01:39 AM
Substitute worksheet function SIGE Excel Programming 3 March 2nd 05 08:18 AM
Using a function from a vba add-in: is that considered an external link Bura Tino Excel Programming 6 May 7th 04 07:59 AM


All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"