256 char limitiations on functions

NelCanDo

New Member
Joined
Oct 17, 2011
Messages
6
this is a copy of a previous post on summing a text string.

Example: 21+12+13.....

The string is of variable length with the possibility of 256 or more chars.

Try Jindon's
Function SumInCell(ByVal txt As String) As Double
SumInCell = Evaluate(Replace(Application.Trim(txt), ",", "+"))
End Function

I tried Jindon's solution as suggested by Armondo Montes which works great...except for one thing. Apparently, there is a limitation of a 256 char text string being passed to the evaluate function. Does anyone know if this problem has been resolved after 2010 or if there is a workaround?

I also tried the following solution with the same results. The function crashes when the array is passed to ubound. I would prefer to use evaluate if there is a way to send it a larger string.

Function SumInCell(ByVal txt)
Dim i As Long
Dim NumArray

If (Application.Trim(txt) = NODATA) Then
SumInCell = NODATA
Else
NumArray = Split(DelimitString(Application.Trim(txt)), "+")
For i = LBound(NumArray) To UBound(NumArray)
SumInCell = SumInCell + NumArray(i)
Next i
'SumInCell = Evaluate(DelimitString(Application.Trim(txt)))
End If
End Function
Thanks in advance
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
VBA as such does not have any char limit. So using native functions, try this:
Code:
Function SumInCell(ByVal txt)
Dim i As Long
Dim NumArray
SumInCell = 0
NumArray = Split(Trim(txt), ",")
For i = LBound(NumArray) To UBound(NumArray)
    SumInCell = SumInCell + NumArray(i)
Next i
End Function
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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