Formula is too long

pnjfksx

New Member
Joined
Jan 30, 2003
Messages
34
I have some rather large cells where I am trying to replace some character strings using a macro. When I use something like

Selection.Replace "<.p>", " "

I get this error

Run-time error '1004': Formula is too long

I have already cut the characters down to 1500 in any cell, but I am still getting a runtime error on some cells. Is there anyway to anticipate this error and keep from manually intervening?

Thank you,
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi pnjfksx,

I seem to remember running into this problem some time ago. I believe that you have to break the cell contents into 1024-character blocks and process each block separately. This means that it is probably best not to try to do the replacement in the cell directly, but rather load the text into a string variable and do the replacement there. Then load the text from the string variable back into the cell. And I believe that you will have to do the operations that load the text to and from the string variable in 1024-character blocks.

Damon
 
Upvote 0

Forum statistics

Threads
1,206,808
Messages
6,074,990
Members
446,112
Latest member
nmz1133

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top