TheRedCardinal
Board Regular
- Joined
- Jul 11, 2019
- Messages
- 243
- Office Version
- 365
- 2021
- Platform
- Windows
This is a continuation of the this thread:
I've managed to get the check working, however I am always getting "False" back from the function even when there is a definite match.
Here is my code:
I must be mixing something up somewhere - what have I done wrong?
Thanks!
Object Required in my Function to match an array
I have a function (taken from here) to determine if a value appears in an array. The value I'm looking for is the last entry in an array, in box 6. I have coded as follows: If ExportArray(UBound(ExportArray), 6) "" Then If IsInArray(ExportArray(UBound(ExportArray), 6).Value...
www.mrexcel.com
I've managed to get the check working, however I am always getting "False" back from the function even when there is a definite match.
Here is my code:
VBA Code:
Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
IsInArray = Not IsError(Application.Match(stringToBeFound, arr, 0))
End Function
VBA Code:
CustomerData = WS3.ListObjects(1).DataBodyRange
'Check Customer Entry is correct
If ExportArray(UBound(ExportArray), 6) <> "" Then
SearchStr = ExportArray(UBound(ExportArray), 6)
If IsInArray(SearchStr, CustomerData) = False Then
MsgBox ("Customer Not Found")
Else
MsgBox ("Customer Found")
End If
End If
I must be mixing something up somewhere - what have I done wrong?
Thanks!