Match function returns error when no match found

MarieBocc

New Member
Joined
Jun 28, 2019
Messages
33
Hello everyone,

Here is what I am trying to do : My userform called selectTr has a listbox in which the user choses one value. I want to check whether I have this value in the third column of my sheet or not and act accordingly so here is my code :

Code:
            Dim found As Integer
            found[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]= Application.Match(Left(selectTr.listTr.Value, 3), Range(Cells(1, 3), Cells(lgnCount, 3)), 0)

            If Not IsError(coordInsert) Then
                MsgBox "Found at lign " & coordInsert
                ...I do things........
            Else
                MsgBox "Not found"
               ... I do something else..........
            End If[/FONT]

I read online that Application.Match supposedly returns #N/A if the value is not found which is why I have this If Not isError(coordInsert).
But the problem is that when the value is not found by the match function, it throws an error message box of type incompatibility.
(Everything works fine when the value is in the column.)

Any idea guys ?

Thank you for reading,

Marie
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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