Results 1 to 1 of 1

Thread: Error 13 - Script out of range

  1. #1
    Neophyte olaxer's Avatar
    Join Date
    Oct 2021
    Posts
    1
    Articles
    0
    Excel Version
    Office 365

    Exclamation Error 13 - Script out of range



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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 p45cal; 2021-10-14 at 05:40 PM. Reason: added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •