I have an array with orders (order date, customer etc) and I need to check whether a specific ID corresponds to a customer.
Here is the function / data below:
If I use CheckCustomer(108,723) I get FALSE - even though the customer is clearly in the table with the correct ID.
As I am working with array data, I was wondering whether the
return 'true' value is overwritten as soon as a 'false' is found in the array.
Is there any other way to search for these value, like with SUMPRODUCT?
Thanks for your help.
Maria
<tbody>
</tbody>
Here is the function / data below:
Code:
Function CheckCustomer(ID As Integer, Customer As Integer) as Boolean
Dim arr() As Variant
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Orders")
arr = ws.Range("tblOrders")
Dim i As Long
'Check if the customer does have such a contract
For i = 1 To UBound(arr)
If arr(i, 2) = Customer And arr(i, 1) = ID Then
CheckCustomer = True
Else
CheckCustomer = False
End If
Next i
End Function
If I use CheckCustomer(108,723) I get FALSE - even though the customer is clearly in the table with the correct ID.
As I am working with array data, I was wondering whether the
return 'true' value is overwritten as soon as a 'false' is found in the array.
Is there any other way to search for these value, like with SUMPRODUCT?
Thanks for your help.
Maria
ID | Customer |
108 | 723 |
159 | 723 |
490 | 723 |
292 | 723 |
381 | 723 |
<tbody>
</tbody>