My Array is returning an Internal Error - but not stopping the macro

TheRedCardinal

Active Member
Joined
Jul 11, 2019
Messages
252
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I have the following function:

VBA Code:
Function FindInvoice(Search As Double, Vector As Variant, SearchArray As Variant) As Long

For MyCount = LBound(SearchArray, 1) To UBound(SearchArray, 1)

    If SearchArray(MyCount, Vector) = Search Then
        FindInvoice = MyCount
        Exit Function
    End If
    
Next MyCount

MyCount = 0

End Function

My whole macro is returning no matches.

I've stepped through this process and all of the variables look right.

When I hover over the "SearchArray(MyCount, Vector) line to see what the variable is, I get <Internal Error> shown.

When I query the same array location in the Immediate bar then I get the (correct) result.

But the macro doesn't crash - it just returns 0 from the function each time.

This process has worked before and the only changes I've made have been in the worksheets themselves, not the code.

Can anybody tell me what this problem could be?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This gives what's in the array...
VBA Code:
FindInvoice = SearchArray(MyCount, Vector)
Mycount is your numeric array index... not sure. Maybe that's what you want instead of what's in the array? HTH. Dave
edit: whoops re-read your query. Maybe the vector's wrong?
 
Upvote 0
Hi thanks for your reply.

Turns out a close and restart was all that was needed!
 
Upvote 0
The mysteries of XL never surprise me anymore. Thanks for posting your outcome and have a nice day. Dave
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top