The issue i'm experiencing is that there is a "Type Mismatch" error after which the Locals Window loses all memory of the values stored in the variables. Therefore, I cannot debug where the problem is coming from.
Preliminary code prior to the occurrence of the issue:
Dim i as Long, j as Long, g as Long
Dim Total_Rows_Help as Long
Total_Rows_Help = Worksheets("Help Worksheet").Range("A" & Rows.Count).End(xlUp).Row
ReDim Min_NDate(2 To Total_Rows_Help, 2 To Total_Rows_Help) As Variant
For i = LBound(Min_NDate, 1) To UBound(Min_NDate, 1)
For j = LBound(Min_NDate, 2) To UBound(Min_NDate, 2)
Min_NDate(i, j) = Worksheets("Help Worksheet").Cells(i, 2) - Worksheets("Help Worksheet").Cells(j, 2)
Next j
Next i
The problem occurs around these sets of loops (the loop and code works until a certain point where it errors. I believe it is due to the Application.Index):
ReDim Count(2 To Total_Rows_Help, 2 To Periods - 1) As Variant
For i = LBound(Min_NDate, 1) To UBound(Min_NDate, 1)
If Application.Large(Application.Index(Min_NDate, i, 0), Periods - 1) < 0 Then
For g = LBound(Count, 2) To UBound(Count, 2)
Count(i, g) = Application.Large(Application.Index(Min_NDate, i, 0), g)
Next g
End If
Next i
Below is the attached excel file and the code is located at the Compiled
Worksheet:
Excel File
Weirdly there are times where it does not allow a Debug option and just instantly ends. However, this time after tweaking the i values, I was able to get a screenshot of the issue:
It crashed on i
values that is +1 away from reaching the upper bound of the loop. However, it should work because Min_NDate
and Count
's number of columns are the same with 2 To Total_Rows_Help
Same problem with the upper bound of the variable, i, was set using the UBound function: