Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Can I trap "formula too long"??

Hi - I have some code that falls over when it tries to read
ActiveCell.Formula when the contents of the cell are too long (good old error
number 1004). It actually happens when there's a long piece of text in the
cell, rather than a formula.

Now the limit for text is 1024 characters but I can't even capture this
error with a (rather clumsy)"If Len(ActiveCell.Value)1024" or similar
because in fact the limit in Excel for the number of characters for real
formulae (rather than just text) appears to be rather variable and certainly
less than 1024.

IsError doesn't seem to catch it. Is there anything else that can, apart
from normal error trapping code (which I don't think is very satisfactory for
the generic 1004 error)? The Watch window says the cell's Formula property
is <Application-defined or object-defined error which, of course, is the
problem: it can't even be read by VBA to then be tested.

Hope you can help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Can I trap "formula too long"??

the limit for text is 32K characters, not 1024. Prior to excel 97, the limit
was 255 characters. The formula is limited to 1024 characters when expressed
in R1C1 format.

if activecell.hasFormula then
msgbox ActiveCell.Formula
else
msgbox ActiveCell.Value
end if

--
Regards,
Tom Ogilvy


"Smallweed" wrote:

Hi - I have some code that falls over when it tries to read
ActiveCell.Formula when the contents of the cell are too long (good old error
number 1004). It actually happens when there's a long piece of text in the
cell, rather than a formula.

Now the limit for text is 1024 characters but I can't even capture this
error with a (rather clumsy)"If Len(ActiveCell.Value)1024" or similar
because in fact the limit in Excel for the number of characters for real
formulae (rather than just text) appears to be rather variable and certainly
less than 1024.

IsError doesn't seem to catch it. Is there anything else that can, apart
from normal error trapping code (which I don't think is very satisfactory for
the generic 1004 error)? The Watch window says the cell's Formula property
is <Application-defined or object-defined error which, of course, is the
problem: it can't even be read by VBA to then be tested.

Hope you can help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
zz zz is offline
external usenet poster
 
Posts: 14
Default Can I trap "formula too long"??

you can always trap the error by number

if err.Number=1004 then
var=range.value
else
var=range.formula
endif

--
--
---
ZZ [underground]
Semi-musico,cuasi-poeta y loco

"Smallweed" wrote in message
...
Hi - I have some code that falls over when it tries to read
ActiveCell.Formula when the contents of the cell are too long (good old
error
number 1004). It actually happens when there's a long piece of text in
the
cell, rather than a formula.

Now the limit for text is 1024 characters but I can't even capture this
error with a (rather clumsy)"If Len(ActiveCell.Value)1024" or similar
because in fact the limit in Excel for the number of characters for real
formulae (rather than just text) appears to be rather variable and
certainly
less than 1024.

IsError doesn't seem to catch it. Is there anything else that can, apart
from normal error trapping code (which I don't think is very satisfactory
for
the generic 1004 error)? The Watch window says the cell's Formula
property
is <Application-defined or object-defined error which, of course, is the
problem: it can't even be read by VBA to then be tested.

Hope you can help.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Can I trap "formula too long"??

Thanks so much Tom - .HasFormula exactly what I needed!

"Tom Ogilvy" wrote:

the limit for text is 32K characters, not 1024. Prior to excel 97, the limit
was 255 characters. The formula is limited to 1024 characters when expressed
in R1C1 format.

if activecell.hasFormula then
msgbox ActiveCell.Formula
else
msgbox ActiveCell.Value
end if

--
Regards,
Tom Ogilvy


"Smallweed" wrote:

Hi - I have some code that falls over when it tries to read
ActiveCell.Formula when the contents of the cell are too long (good old error
number 1004). It actually happens when there's a long piece of text in the
cell, rather than a formula.

Now the limit for text is 1024 characters but I can't even capture this
error with a (rather clumsy)"If Len(ActiveCell.Value)1024" or similar
because in fact the limit in Excel for the number of characters for real
formulae (rather than just text) appears to be rather variable and certainly
less than 1024.

IsError doesn't seem to catch it. Is there anything else that can, apart
from normal error trapping code (which I don't think is very satisfactory for
the generic 1004 error)? The Watch window says the cell's Formula property
is <Application-defined or object-defined error which, of course, is the
problem: it can't even be read by VBA to then be tested.

Hope you can help.

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
Spell check giving "formula too long" - doesn't make corrections JIM Excel Discussion (Misc queries) 3 September 4th 08 12:28 AM
How to "copy-down" a formula in a Very LONG Column? Mark246 Excel Discussion (Misc queries) 4 February 26th 08 11:20 PM
While using find and replace i am getting "formula too long" venkat Excel Discussion (Misc queries) 4 November 26th 06 01:24 PM
"formula is too long" AND test for whether double-quotes are next-to text or number?? The Moose Excel Discussion (Misc queries) 2 September 14th 06 05:29 AM
"Formula too long" when changing linked sources?? fred at pha Excel Discussion (Misc queries) 2 July 20th 06 03:18 PM


All times are GMT +1. The time now is 11:48 PM.

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

About Us

"It's about Microsoft Excel"