Excel versions and limits on the length of string elements in arrays returned by UDFs

I know that different versions of Excel are subject to different limits on the length of strings that may appear within arrays returned to a worksheet from a VBA UDF.

For Excel 365 (Sep 2021) the limit is 32,767, which is also the limit on the length of string that any cell can contain. For Excel 2010, the limit was 255.

I'd like to know what the limit was for Excel 2013, Excel 2016 and Excel 2019. At which version did Microsoft up the limit?

Here's a function to test the limit:

Function TestStringLengthLimit(N As Long)
    Dim Result(1 To 2, 1 To 1) As Variant

    Result(1, 1) = String(N, "x")
    Result(2, 1) = N 'Result needs to hold both Longs and Strings

    TestStringLengthLimit = Result

End Function

When the function is called from a worksheet cell, if N is greater then the limit Excel displays #VALUE! as the function return.

I'd be grateful for answers for Excel 2013, Excel 2016 and Excel 2019. A straightforward way to provide an answer (assuming you have one of the "old" Excels installed) would be to:

  1. Click the link below to a simple test worksheet. https://1drv.ms/x/s!AlVTEdRItFFCndJAvz-ZwyWfxlNUkA?e=hDPMDk
  2. Click the "Editing v" button above the worksheet, and select "Open in Desktop App".
  3. That should open the worksheet.
  4. Recalculate the worksheet (F9) and let me know (via an answer to this question) what "Answers" are in cells A17:B23.

In Excel 365, the Answers look like this:

Answers on Excel 365



from Recent Questions - Stack Overflow https://ift.tt/3o43LqS
https://ift.tt/2W7St9z

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)