Formula longer than 8192 characters. Identify cell?

jakobt

Active Member
Joined
May 31, 2010
Messages
337
Receive an error:
"One or more formulas in this workbook are longer than allowed limit of 8192 characters. To avoid this limitation, save the workbook in excel binary workbook format."

Workbook contains thousands of used cells. How can I identify the cell that is longer than 8192 characters?
Would prefer not to save as binary format!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
How about
Code:
Sub jakobt()
   Dim Ws As Worksheet
   Dim Cl As Range
   
   For Each Ws In Worksheets
      For Each Cl In Ws.UsedRange.SpecialCells(xlFormulas)
         If Len(Cl.Formula) > 8192 Then Cl.Interior.Color = 45678
      Next Cl
   Next Ws
End Sub
 
Upvote 0
That must be a truly hideous formula. You could find it using code like this:

Code:
Sub findGodawfulFormulas()
    Const TOO_LONG As Long = 8192
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
        Dim rgFormulas As Range
        On Error Resume Next
        Set rgFormulas = ws.UsedRange.SpecialCells(xlCellTypeFormulas)
        On Error GoTo 0
        If Not rgFormulas Is Nothing Then
            Dim cell As Range
            For Each cell In rgFormulas.Cells
                If Len(cell.Formula) > TOO_LONG Then
                    Application.Goto cell, True
                    Exit Sub
                End If
            Next cell
            Set rgFormulas = Nothing
        End If
    Next ws
    MsgBox "All sheets checked"
End Sub
 
Upvote 0
What worked for me to diagnose the issue was to save the file as an Excel 97-2003 Workbook. Rather than the BS statement about being unable to do so because of the 8192 character formula limit (which also popped up when I tried saving as an Excel Binary Workbook as the message suggested), it provided actual meaty information about the problem.

(In my case it was an outdated-and-no-longer used entry in the Data Consolidation references. It looks like every time the workbook was edited and saved with a different name, the reference there got a little longer until it exceeded the 8192 character limit. Deleting that reference - which was to a file that was no longer present in any event - enabled me to save the file.)

Cheers,
Biff
 
Upvote 0

Forum statistics

Threads
1,223,865
Messages
6,175,058
Members
452,610
Latest member
Sherijoe

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