ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   IsNA(match (https://www.excelbanter.com/excel-worksheet-functions/27344-isna-match.html)

Sanz

IsNA(match
 
Hi All

Was wondering if you could help me, I have the following function:

Function NOT_IN(value, range)


NOT_IN = Application.IsNA(Application.Match(1, "C6:j6", 0))

End Function

The Function reads False in the cell no matter what I do, can anyone help??

Dave Peterson

I'd use something like:

Option Explicit
Function NOT_IN(myValue As Variant, myRange As Range) As Boolean
NOT_IN = CBool(IsError(Application.Match(myValue, myRange, 0)))
End Function

Tested with:
Sub testme()
MsgBox NOT_IN("asdf", Worksheets("sheet1").Range("a1:A99"))
End Sub

I'd stay away from variables named Value and Range.

Sanz wrote:

Hi All

Was wondering if you could help me, I have the following function:

Function NOT_IN(value, range)


NOT_IN = Application.IsNA(Application.Match(1, "C6:j6", 0))

End Function

The Function reads False in the cell no matter what I do, can anyone help??


--

Dave Peterson


All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com