问题
When running a Dynamic array that is populated I am trying to get the contents of an element and receive the following error Run-Time Error '16': Expression too complex.
The expression that is to complex?
Impactdays is a long, I populated the spreadsheet by simply stuffing the range into the array
ReportArray = Impact_Chart.Range("Data.EventNumber").CurrentRegion.Value
For i = LBound(ReportArray) + 1 To UBound(ReportArray)
If ReportArray(i, iImpactCol) > 0 Then
iImpactDays = ReportArray(i, iImpactCol)<-- Tosses error here
'more stuff
any ideas oh gurus of everything? :) Oh this is 2007
回答1:
Check if you are not using something like
If (Not MyArray) = -1
somewhere in your program. It has been reported a connection between that and your error.
HTH!
回答2:
I did remove the offending stack pointer and used the following to check instead
Function IsArrayDimensioned(TargetArray() As Variant) As Boolean
Dim s As Integer
On Error Resume Next
s = UBound(TargetArray, 1)
If Err.Number = 0 Then
IsArrayDimensioned = True
Else
IsArrayDimensioned = False
End If
End Function
Works as advertised
来源:https://stackoverflow.com/questions/4838000/vba-error-code-run-time-error-16-too-complex