Error 13 - Script out of range

olaxer

New member
Joined
Oct 10, 2021
Messages
1
Reaction score
0
Points
0
Excel Version(s)
Office 365
I am getting some errors on my excel sheet, it works fine when there is an input but when there is no input, I get this error.

Error 13 - Script out of range.

Here is the code -
What could be the problem?

Code:
Private Function GetHighCountIndex(arr1 As Variant, arr2 As Variant) As Variant
Dim Hi As Long
Dim Hi2 As Long
Dim Hi3 As Long
Hi2 = -1
Hi3 = -1
For Hi = LBound(arr2) To UBound(arr2)
  If arr2(Hi) = Range("A28").Value Then
    If Hi3 = -1 Then
      Hi3 = 0
      'Error Here
      Hi2 = arr1(Hi2)
      'Error Here
    ElseIf CDbl(Hi2) < CDbl(arr1(Hi)) Then
      Hi2 = arr1(Hi)
    End If
  End If
Next Hi
GetHighCountIndex = Hi2
End Function


Private Function GetLowCountIndex(arr1 As Variant, arr2 As Variant) As Variant
Dim Li As Long
Dim Li2 As Long
Dim Li3 As Long
Li2 = -1
Li3 = -1
For Li = LBound(arr2) To UBound(arr2)
  If arr2(Li) = Range("A30").Value Then
    If Li3 = -1 Then
      Li3 = 0
      'Error Here
      Li2 = arr1(Li)
      'Error Here
    ElseIf CDbl(Li2) > CDbl(arr1(Li)) Then
      Li2 = arr1(Li)
    End If
  End If
Next Li
GetLowCountIndex = Li2
End Function
 
Last edited by a moderator:
Back
Top