Rubberduck
Rubberduck copied to clipboard
Inspection for use of Evaluate argument/return value that exceeds 255 characters
So it seems Excel limits the input argument (and the return value) to an Evaluate call, to 255 characters, regardless of whether the external identifier syntax (square brackets), or the Evaluate function is used.
I'm uncertain if similar limits apply to evaluated expressions in other hosts.
Dim x As Variant 'As String
'255 character arguments are OK
x = [=CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE("ABCDE")))))))))))))))))))]
x = Evaluate("=CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(""ABCDE"")))))))))))))))))))")
'255 character return values are OK
x = [REPT("A",255)]
x = Evaluate("REPT(""A"", 255)")
'256 character arguments are NOT OK
'x is assigned value Error 2015 - #VALUE!
'If x is declared as String, then runtime error 13 - Type Mismatch occurs
'Syntax error:
x = [=CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE("ABCDEF")))))))))))))))))))]
x = Evaluate("=CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(CONCATENATE(""ABCDEF"")))))))))))))))))))")
'256 character return values are NOT OK
'x is assigned value Error 2015 - #VALUE!
'If x is declared as String, then runtime error 13 - Type Mismatch occurs
x = [REPT("A",256)]
x = Evaluate("REPT(""A"", 256)")
Let's add inspections that identify arguments and return values that might exceed 255 characters.